开发者

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

开发者 https://www.devze.com 2022-12-31 21:52 出处:网络
On Admin > Edit Posts (edit.php), how can I filter for a Custom Taxonomy and see posts of ANY status, not just Published?

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:

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消