Support » Fixing WordPress » Want to leave out certain categories from recent posts

  • I’d like to be able to exclude a certain category from my recent posts. However, I do not know how to do this. I am very new to wordpress, and not real savvy with altering code, but with a decent walk-through I can manage just fine. If someone knows of a link to this sort of information or has the patience to help me, I’d be greatly appreciative. I’ve tried to do a search in the codex, in search engines, and also in WordPress support forum but found nothing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • add this code just before the loop

    <?php query_posts('cat=-4'); ?>

    and then this code after the loop

    <?php wp_reset_query(); ?>

    The function query_posts(); narrows wordpress’ search of the database, in this case, ‘-4’ means it will exclude all posts from the category with an id of 4 when running the loop.

    You should only use this function once though, in the main page, every additional time you must use WP_Query();

    Check out this page

    I am trying to accomplish much same thing in the sidebar. I’d like to show the recent post from a certain category while excluding other categories from the list.

    Is there a pluggin or widget that will make this a simple process? I know nothing about PHP or how to implement it.

    Any help you can provide is much appreciated.

    ~ John

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Want to leave out certain categories from recent posts’ is closed to new replies.