Support » Fixing WordPress » Exclude post in sidebar based on selection

  • Resolved cboakes



    I am trying to display posts in a way where the sidebar displays the excerpts of two recent posts and the middle of the page displays the full post when the post in the sidebar is selected. I have been able to do this by modifying the ‘single.php’ file.

    However I don’t know how to exclude the post in the middle from the sidebar?

    Can anybody point me in the right direction on how to do this?



Viewing 2 replies - 1 through 2 (of 2 total)
  • cboakes


    I’ve figured out what I think is the best way to approach it but I still need help with its completion:
    I use:
    <?php query_posts(array('category_name' => 'news', 'post__not_in' => array(31))); ?>
    This would exclude, in this instance, the post with the ID of 31.

    So now I need to make it dynamic. My knowledge of php isn’t great, but I thought declaring a variable of the current post would work, so something like:

    $excludeid = 31;
    query_posts(array('category_name' => 'news', 'post__not_in' => array($excludeid)));

    This worked fine. So to make it dynamic my logic was to go with:
    $excludeid = the_ID();

    But this just doesn’t work, would anybody help me to try and make this dynamic?




    Figured it out, thanks to this article:

    So the variable needed to be declared as:

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude post in sidebar based on selection’ is closed to new replies.