• vjart

    (@vjart)


    Hello All!
    I want to display links to posts on top of a page (this is an easy part), and then I want that when one of those links is clicked that post is displayed underneath the links. When the page first loads I want the 1st post in the list of links to be displayed underneath the links.
    This is what I currently have…
    for the top links:

    <ul>
    <?php
         global $post;
         $posts = get_posts('numberposts=4&category=3');
         foreach($posts as $post) :
         setup_postdata($post);
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>

    and for the post:

    <?php
        $posts = get_posts("cat=3&showposts=1");
        if ($posts) {
                     foreach ($posts as $post):
                     setup_postdata($post); ?>
      <h1><?php the_title(); ?></h1>
     <?php the_content(); ?>
     <?php endforeach; } ?>

    What I get is when I click on the links always the latest post gets displayed, not the one that the_permalink() is for.
    What do I do wrong? Please help.

  • The topic ‘How does a post get displayed when link generated by the_permalink() is clicked’ is closed to new replies.