WordPress.org

Ready to get started?Download WordPress

Forums

get_posts - exclude one or more categories (3 posts)

  1. 3stripe
    Member
    Posted 8 years ago #

    Hi folks,

    I've searched about for answers to this but can't find anything that works.

    How can I modify my query so that it exlucdes a particular category?

    <?php $posts = get_posts('numberposts=15'); foreach ($posts as $post) : ?>

    I can specify to show only one category, say numberposts=15&category=1, but the reverse, numberposts=15&category=-1 gives me an error.

    Confused!

    Thanks for your time

  2. berchman
    Member
    Posted 8 years ago #

    I believe you use the "exclude" option.

    exclude=1

  3. KatGirl
    Member
    Posted 8 years ago #

    edit: I've given the wrong answer. Sorry

Topic Closed

This topic has been closed to new replies.

About this Topic