如果想将一些特定分类中的文章不在wordpress的Blog页面显示,下面的方法可以帮你方便地排除特定分类的文章。
复制下面的代码到你的主题functions.php文件:
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( ‘cat’, ‘-5, -34’ );
}
return $query;
}
add_filter( ‘pre_get_posts’, ‘exclude_category_home’ );
替换上面的数字为想要过滤的文章分类即可。