WordPress.org

Ready to get started?Download WordPress

Forums

Show posts but exclude a specific tag (2 posts)

  1. trmash
    Member
    Posted 2 years ago #

    Hi all,

    I know there's a few posts to this effect on the forum, but to be honest I'm feeling like a bit of a gumby because I can't figure out how to make it work.

    I am displaying all posts from one category with the following (please feel free to correct if it's wrong).

    <?php $section_headlines = new WP_Query('cat=6') ?>
    <?php if ( $section_headlines->have_posts() ) ... etc

    How do I exclude a specific tag from this query? And where do I put it? Does it need to go in my if/while statement?

    Thanks!

  2. trmash
    Member
    Posted 2 years ago #

    So I may have been having a senior moment - turns out I was editing the wrong file (just been tidying up my theme).

    This seems to be doing the trick, but feedback is still welcomed.

    <?php $section_headlines = new WP_Query(array('tag__not_in'=>'70','cat=6')) ?>

    Thanks.

    ETA: Okay, so now I'm VERY confused. The above code causes the category number to be ignored. So it's a bit of a fail so far. Back to square one. :(

Topic Closed

This topic has been closed to new replies.

About this Topic