Excluding one category in Wordpress

2019-08-23 21:50发布

I just started out using wordpress as a CMS. On the site I have 2 pages I want different posts to show on. So far I understand this small code to post only one particular category one a page (when put infront of the loop:

<?php query_posts('cat=8&showposts=5');?>

But what do I write when I need to exclude this category on my blog-page?

2条回答
\"骚年 ilove
2楼-- · 2019-08-23 22:31

You should only include the loop/category you want displayed on each page. Meaning you should have an index page and your secondary page should be a separate file within your template file. Then edit your categories accordingly.

index.php - query_posts('cat=BLOG&showposts=5');

other.php - query_posts('cat=OTHER&showposts=5');

Then create your page within the administration panel accordingly.

查看更多
相关推荐>>
3楼-- · 2019-08-23 22:34

Just add a minus to it. Example:

query_posts('cat=-3');
查看更多
登录 后发表回答