Default categories are populated like this →

                if( $terms = get_terms( 'category', 'orderby=name' ) ) : // to make it simple I use default categories
                    echo '<select name="categoryfilter"><option value="all">All</option>';
                    foreach ( $terms as $term ) :
                        echo '<option value="' . $term->slug . '">' . $term->name . '</option>'; // ID of the category as the value of an option
                    echo '</select>';

enter image description here

I tried to put vcategory instead of category, but it didn't work.

  • Please provide more details, it is not clear what you are trying to achive. Do you want to show all custom post type categories? Commented Jun 1, 2018 at 7:14
  • Yes, thats right.
    – WordCent
    Commented Jun 1, 2018 at 7:32

1 Answer 1


The second param fort historia function is deprecated, so it would be much nicer to pass params as an array:

$terms = get_terms( array(
    'taxonomy' => 'vcategory',
    'hide_empty' => false,

) );

But if you want to show a select filled with terms of given taxonomy, there’s a function for that:

wp_dropdown_categories( array(
    'show_option_all'    => 'All',
    'orderby'            => 'name',
    'order'              => 'ASC',
    'hide_empty'         => 1, // change to 0 if empty terms should be shown to
    'echo'               => 1,
    'selected'           => 0,
    'name'               => 'categoryfilter',
    'taxonomy'           => 'vcategory',
    'value_field'        => 'slug',
) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.