Forums

Select "!=" (4 posts)

  1. zszalbot
    Member
    Posted 3 years ago #

    Hello,

    I would like to know how to write a negative select query:

    $myposts = get_posts('category=3&numberposts=5&offset=0');

    I would actually like to select all posts BUT those who are in category 3. How can I do that?

    Many thanks!

  2. kwbridge
    Member
    Posted 3 years ago #

    The section Exclude Posts from Some Category a little down the page should help.

    http://codex.wordpress.org/The_Loop

  3. zszalbot
    Member
    Posted 3 years ago #

    Thank you! I think this is what I need!

    Just one final question.

    <?php if (in_category('3')) continue; ?>

    If I wanted to exclude more than one category, can I write it as:

    <?php if (in_category('3')) or (in_category('4')) continue; ?>

    Thanks!

    Zbyszek

  4. kwbridge
    Member
    Posted 3 years ago #

    You might want to try this instead.

    http://codex.wordpress.org/Template_Tags/query_posts

Topic Closed

This topic has been closed to new replies.

About this Topic