show_count in wp_dropdown_categories not counting draft posts

by Braineack   Last Updated March 14, 2019 20:08 PM - source

I'm using wp_dropdown_categories in the restrict_manage_posts hook to build a filter for the various post_formats.

It works correctly, but it seems to only be counting published posts, and won't count any posts which are draft.

function _restrict_manage_posts_format()
    wp_dropdown_categories( array(
         'taxonomy'         => 'post_format',
         'hide_empty'       => 1,
         'show_count'       => 1,
         'name'             => 'p_format',
         'show_option_none' => 'All Formats',
         'selected'         => $post_format_ID
    ) );
add_action( 'restrict_manage_posts', '_restrict_manage_posts_format' );

Is there a better way to render the list that will match the count of posts being returned for each format?

Tags : posts filters

Answers 1

You're telling it to hide the empty drafts.

Setting hide_empty to 0 (false) in your arguments will display all terms, even the "empty" ones.

so change

     'hide_empty'       => 1,


     'hide_empty'       => 0,
March 14, 2019 20:06 PM

Related Questions

Exclude category on blog list page

Updated April 29, 2018 08:08 AM

Filter Posts By Tag

Updated December 07, 2017 18:08 PM