Forums

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

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33169
    Roxon
    Member

    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)

    #81920
    TheDoc
    Member

    Instead of ‘-snippet’, try to find the ID number of the tag and use that instead.

    #81949
    Roxon
    Member

    @TheDoc: I can’t believe I didn’t think about that earlier. Wow, thanks a lot.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.