• I’m using a piece of code to display the latest 10 posts from a certain tag in a post:

    <ul>
     <?php
     global $post;
     $myposts = get_posts('numberposts=10&tag=tagname');
     foreach($myposts as $post) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
    </ul>

    When I use it in a page it works fine and correctly displays the latest ten posts with the relevant tag.

    But when I use it in a post although it correctly displays the latest posts it also interferes with the comments that are displayed below the post: it displays the comments from the last post described in the list.

    I can’t work out what I’ve done wrong with the code – can anyone help please?

    I’m using the Exec PHP plugin to execute PHP code in posts.

  • The topic ‘Code to display links from tags is messing comments up’ is closed to new replies.