简体   繁体   中英

WP Admin: Filter for a Custom Taxonomy and see posts of any/all status?

On Admin > Edit Posts (edit.php), how can I filter for a Custom Taxonomy and see posts of ANY status, not just Published?

For example, say I have a Custom Taxonomy "Color"...

These queries find posts of ANY status:

  • edit.php?category_name=foo
  • edit.php?author=3
  • edit.php?tag=foo

And this query works correctly:

  • edit.php?color=red&post_status=draft

But this query finds ONLY Published posts:

  • edit.php?color=red

Drop this in a plugin or your theme's functions.php ;

if (is_admin()):

function my_query_parser(&$query)
{
    if (!isset($_GET['post_status']))
        $query->query_vars['post_status'] = 'any';
}
add_action('parse_query', 'my_query_parser');

endif;

Personally I would class this as a bug in WP, I'll post it up in trac.

UPDATE:

It seems this trac entry mentions the issue, and it's reportedly fixed (probably in the nightly build).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM