过滤器打开pre_get_posts
应该这样做。
function hide_author_wpse_138491($qry) {
$exc = 123;
if (
!is_admin()
&& !is_singular()
) {
$qry->set(\'author\',\'-\'.$exc);
}
}
add_action(\'pre_get_posts\',\'hide_author_wpse_138491\');
这应该排除所有前端页面上ID=123的作者的结果,除了“单一”页面,这听起来像是您的目标——即“完全隐藏作者X在搜索、类别、分类页面等中的所有帖子”