方法:修改主题的functions.php文件

//在首页中排除某些分类
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-16, -17' ); //你要排除的分类ID
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );
感谢您的来访,获取更多精彩文章请收藏本站。

方法:修改主题的functions.php文件

//在首页中排除某些分类
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-16, -17' ); //你要排除的分类ID
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );