WordPress.org

Forums

Single page : prevent same post from appearing in sidebar ? (2 posts)

  1. frmars
    Member
    Posted 5 years ago #

    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) :
       setup_postdata($post);
     ?>
        <li <?php the_post_thumbnail();?>
    <a href="<?php the_permalink(); ?>">
    <?php the_title(); ?></a>
    <?php the_excerpt(); ?>
    
    <?php endif; ?></li>
     <?php endforeach; ?>
    </ul>
  2. frmars
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic