Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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' );
share|improve this question
    
Are you using wp_dropdown_categories –  Pieter Goosen Jun 3 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> –  Adam Lundberg Jun 3 at 10:06
    
You should add this info in an edit –  Pieter Goosen Jun 3 at 10:14

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
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 at 10:24
    
I got it working, thanks! –  Adam Lundberg Jun 3 at 10:32
1  
@birgire thanks, typo –  Pieter Goosen Jun 3 at 12:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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