WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Stop current post featuring in recent post on single.php (3 posts)

  1. DLOnline
    Member
    Posted 1 year ago #

    I am running a custom query for my recent posts, code can bee seen at:
    http://pastebin.com/CFZdP3c9

    My problem is that it shows my current page post item and I cannot figure out how to pass over it.

    originally I tried

    global $post;
    $currentPost = $post->ID;
     if( $post->ID != $currentPost ) ?>
        (the loop)
    endif;

    but could not seem to get it to work correctly, it just didn't output anything.

    Any insights are greatly appreciated!

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    try to use the 'post__not_in' parameter within a WP_Query();

    http://pastebin.com/bUFz0PCN

    http://codex.wordpress.org/Class_Reference/WP_Query

    (untested)

  3. DLOnline
    Member
    Posted 1 year ago #

    I re-wrote the query using a foreach loop and used and args array like mentioned above. Thanks! :-)

Topic Closed

This topic has been closed to new replies.

About this Topic