一、找到分类id。可以在数据库中直接查找
二、找到主题当中的function.php所在目录/wordpress/wp-content/themes/增加如下代码
1 2 3 4 5 6 7 |
//在首页中排除某些分类 function exclude_category_home( $query ) { if ( $query->is_home ) { $query->set( 'cat', '-155, -30' ); //你要排除的分类ID } return $query; }add_filter( 'pre_get_posts', 'exclude_category_home' ); |