Answer the question
In order to leave comments, you need to log in
How to make a select dropdown list with WordPress taxonomies?
There is a category taxonomy.
It has a structure
Category 1 - Sub-category 1
Category 1 - Sub-category 2
I do select like this:
<?php
$categories = get_terms(
'company_category',
array( 'hide_empty' => false, 'parent' => 0 )
); ?>
<select name="catID" id="cat">
<?php
foreach ($categories as $category) {
$catID = $category->term_id;
$catName = $category->name;
?>
<option value="<?= $catID; ?>"><?= $catName; ?></option>
<?php } ?>
</select>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question