Remove single post from query (3 posts)

  1. cjhmdm
    Posted 5 years ago #

    Hello, I have 2 queries on my single post page (single.php). My first query shows the full post for the article clicked, the second query shows the 3 latest posts in excerpt format, which happens to include the actual post being displayed.

    I'm using arras theme, and the double query is required, what I'm wondering is, is there a way to show the latest 3 posts in query 2 except for the full post being shown on that page?

    Since I suck at explaining, here's an example:


    When mydomain/posts/newest is viewed, query 2 shows 2nd_newest, 3rd_newest and 4th_newest

    When mydomain/posts/2nd_newest is viewed, query 2 shows newest, 3rd_newest and 4th_newest

    When mydomain/posts/3rd_newest is viewed, query 2 shows newest, 2nd_newest and 4th_newest

    And so on and so forth.

    Is something like this possible? Thanks in advance for any enlightnement :)

  2. MichaelH
    Posted 5 years ago #

    Before you first loop, the loop that displays the single post, put


    and inside that first loop put:


    Then for your 2nd query something like:

      'post__not_in' => array($nodup),
    $my_query = new WP_Query($args);
  3. Maxaud
    Posted 5 years ago #

    pretty useful code.

Topic Closed

This topic has been closed to new replies.

About this Topic