Excluding one category in Wordpress

804 Views Asked by At

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

There are 2 best solutions below

3
Bjoern On BEST ANSWER

Just add a minus to it. Example:

query_posts('cat=-3');
0
listenrightmeow On

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.