一般情况下博客首页显示的都是最新日志,如果想将一些特定分类中的文章不在首页显示,下面的方法可以帮你方便地在首页排除特定分类的文章。
复制下面的代码到你的主题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' );
修改第3行的分类ID,然后保存文件,就大功告成了。
原文:http://www.wprecipes.com/how-to-exclude-specific-categories-from-your-blog-homepage
沟通咨询
+ 微信号 505969590 或扫码
