admin管理员组文章数量:1125106
I am logged on as admin
I am on the Posts dashboard
I have Posts assigned to multiple Categories and I have posts that are assigned to only one category.
I want to display posts that are assigned to only one category.
if a post is assigned to multiple categories, then it that post should not be displayed.
The result should be posts that are assigned to one category and as I edit them and assign them to more than one category, the Post will not show in the List after I click save.
How can this be done?
I am logged on as admin
I am on the Posts dashboard
I have Posts assigned to multiple Categories and I have posts that are assigned to only one category.
I want to display posts that are assigned to only one category.
if a post is assigned to multiple categories, then it that post should not be displayed.
The result should be posts that are assigned to one category and as I edit them and assign them to more than one category, the Post will not show in the List after I click save.
How can this be done?
Share Improve this question asked Mar 8, 2017 at 3:09 Joseph ButlerJoseph Butler 311 bronze badge1 Answer
Reset to default 0You can hook into the load-edit.php
action to modify how wp-admin lists pages. Add this to your functions.php:
<?php
add_action( 'load-edit.php', 'namespace_modify_admin_list' );
function namespace_modify_admin_list() {
global $typenow;
if ( 'post' !== $typenow )
return;
add_action( 'pre_get_posts', 'namespace_modify_admin_list_posts' );
}
function namespace_modify_admin_list_posts( $query ) {
/**
* Modify query here to change how posts are listed, using
* the set method of the query object.
*
* Example:
* $query->set( 'posts_per_page', 10 );
*/
}
?>
May I ask why would you want to hide posts that have more than one category? Is this for access-control or filtering purposes?
本文标签: sortFilter Posts by Excluding Categories
版权声明:本文标题:sort - Filter Posts by Excluding Categories 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736650878a1946138.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论