Support » Themes and Templates » Single page : prevent same post from appearing in sidebar ?

  • Hello

    I have in my theme a nice and rather classical list of “Recents articles” showing title, excerpts, thumbnails, and read more.

    Works fine.

    But let us say I click on the first excerpt. I am now reading the whole article, with its full size picture.

    Fine too.

    Problem : in the sidebar, next to the article, I still have my “recent articles” showing… And very logically showing the exact same (smaller) picture, the same title, and the same text (excerpt).

    Aaargh !

    Is there a way to tell WP :
    “if article already displayed, do not show in list of recent posts” ?

    my code for my recent articles :

    <ul ><?php
     global $post;
     $myposts = get_posts('cat=6&numberposts=15');
     foreach($myposts as $post) :
        <li <?php the_post_thumbnail();?>
    <a href="<?php the_permalink(); ?>">
    <?php the_title(); ?></a>
    <?php the_excerpt(); ?>
    <?php endif; ?></li>
     <?php endforeach; ?>
Viewing 1 replies (of 1 total)
  • May I add that a very basic user. Copying a few instructions is ok. Nothing more. I dread everything with variables and arrays. Just can’t do it, can”t “think” it. Gives me instant brain-ache.

Viewing 1 replies (of 1 total)
  • The topic ‘Single page : prevent same post from appearing in sidebar ?’ is closed to new replies.