有时候我们也会设置一些分类目录是不想让首页显示的,我们可以这样修改。
1,打开主题首页文件index.php找到如下代码:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
修改为:
<?php if ( have_posts() ): query_posts($query_string .’&cat=-9′); ?>
可以把两条语句合并为一条最终修改为:
<?php if ( have_posts() ) : query_posts($query_string .’&cat=-9′); while ( have_posts() ) : the_post(); ?>
其中cat=-9的9就是不想让在首页显示的ID,有人问了怎么知道分类目录ID呢?
进入后台–文章–分类目录,把你鼠标放在要禁止显示的分类目录上面就会看到了如图:
想了解更多的首页显示文章的方式就进入:
https://sdeno.com/调用wordpress函数汇总/