<?php query_posts('cat=-3'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h3></h3>
<p><?php the_time('F jS, Y') ?></p>
<?php the_content(); ?>
<?php endwhile; ?>
The area inside the while loop could be anything, that’s just some example typical inside-loop code. The trick is the first line, and the cat=-3 parameter. -3
in this case is the ID of the category, and you can replace that with any category you wish to remove from the loop. You may use comma separated values here to remove more than one category (e.g. cat=-1,-2
).
I use that so i can have 2 pages that display different posts one display the news and the other my latest work everything works fine but for some reason the read more button does not appear any suggestions thanks
Hi
Do you know how to code this if you used /work/ instead of an id.
Thanks
i use it within looping. is it ok?
here..
because i’m using wp_pagenavi… is it ok?
Messed with pagination, you guys should check some things before starting giving tips.
Something goes wrong with the pagination. As in it hides the category specified but certain non-specified categories don’t show up. Seems, that the solution provided by you guys messes up the pagination code. Please Help !!!
Uhh, not sure what happened, but I meant to post that even though this post is a little old, people who come across it today might want to take care in using $query_posts() since it can be a very risky function. I’d suggest using WP_Query() instead.
Here’s a sample from a project I’m working on now (which…uhm, you got a little sample of above…)
Brilliant, this is exactly what I was looking for. Thank you Aaron.
@Dexter
Thank You victor, your code has come handy for one of my website. Thanks a lot!!
Excluding specific categories in certain pages seems to be more tricky.
This code below for exmaple does not work. Any idea what to do if I want to show certain categories on certain pages (= excluding the rest)?