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 am trying to use wp_dropdown_categories at front end. I got the dropdown box with default "uncategorized", the rest of the category is not there.

function cats_dropdown(){
    require_once(ABSPATH . '/wp-admin/includes/template.php');
    $args = array('taxonomy' => 'category');
?>
  <div>
     <?php wp_dropdown_categories($args); ?>
  </div>
<?php
}

In the same function, if I try to output wp_terms_checklist, it works. This is confusing. Anything I missed in the dropdown?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

It could be that it won't show empty categories, categories that has no posts attached to them.

Try to change $args = array('taxonomy' => 'category'); to $args = array('taxonomy' => 'category', 'hide_empty' => 0);

share|improve this answer

You shouldn't need to define the taxonomy of category as that's the default. Have you tried just using the following?

<?php $args = array('show_option_none' => 'Categories', hide_empty => '0'); ?>
<?php wp_dropdown_categories($args); ?>
share|improve this answer

By default, wp_dropdown_categories only displays the categories that have posts. Set hide_empty argument to false to display all categories, even those without posts.

$args = array(
    'taxonomy'   => 'category'
    'hide_empty' => false
);
wp_dropdown_categories($args);

On the other hand, wp_terms_checklist will display all categories, even if they are empty.

share|improve this answer

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.