The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › Back End › WordPress: return all posts except of a certain tag
I want the “latest post” section of my site to have the title, link etc of the latest post UNLESS it’s a snippet (tagged with “snippet”). I have no idea why this code isn’t doing it.
$args = array(
'posts_per_page' => '1',
'tag' => '-snippet' // "-" denotes all except
$real_posts = new WP_query($args);
have_posts() ) : $real_posts->the_post(); ?>
LATEST POST •
It just returns that latest post, regardless of tag. So right now my latest post is tagged with snippet, but it still outputs it. So frustrating. Any suggestions? (I tried the same thing with category already)
Instead of ‘-snippet’, try to find the ID number of the tag and use that instead.
@TheDoc: I can’t believe I didn’t think about that earlier. Wow, thanks a lot.