0

I have created a front end post with a form and I would like to have several categories for the user to choose between. But the problem is that the dropdown category only show those categories that are in use. I need it to show all categories even if they are not in use.

The code I'm using is following:

wp_dropdown_categories(   'show_option_none=Kategori&tab_index=4&taxo. nomy=register_vote_category' );
3
  • Are you using wp_dropdown_categories Jun 3, 2014 at 10:02
  • Yes, I forgot to say that. I'm currently using <p><?php wp_dropdown_categories( 'show_option_none=Kategori&tab_index=4&taxonomy=register_vote_category' ); ?></p> Jun 3, 2014 at 10:06
  • You should add this info in an edit Jun 3, 2014 at 10:14

1 Answer 1

2

wp_dropdown_categories() has a parameter specially to hide or to show empty categories.

hide_empty

(boolean) (optional) Show (0/False) or hide (1/True) category with no posts.

Default: 1/True

You can simply just

 hide_empty=0

to your arguments

1
  • 1
    +1 This is most likely what the OP is looking for. I misread the question and thought he only wanted to show the empty categories ;-) ps You wrote wp_list_categories instead of wp_dropdown_categories.
    – birgire
    Jun 3, 2014 at 10:24

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.