Excluding one category in Wordpress

2019-08-23 21:54发布

问题:

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?

回答1:

Just add a minus to it. Example:

query_posts('cat=-3');


回答2:

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.