Support » Fixing WordPress » Link to newest post?

  • Resolved Kevin Kwok

    (@queesy)


    I’m trying to link my visitors to my newest post on my website. I want them to view the post in their entirety but I have been searching and searching for a day now and cannot find the solution.

    I found this code on the forums but it only displays info such as date and title of the newest post.

    <?php $postslist = get_posts('numberposts=1'); ?>
    <?php foreach ($postslist as $post) : setup_postdata($post); ?>
    <li class="lnk2">
      <?php the_date(); ?><br /><?php the_title(); ?>
    </li>
    <?php endforeach; ?>

    Does anyone have a solution? =(

Viewing 2 replies - 1 through 2 (of 2 total)
  • Use the_content() to print the full post, you can replace your code with the following:

    <?php $postslist = get_posts('numberposts=1'); ?>
    <?php foreach ($postslist as $post) : setup_postdata($post); ?>
    <li class="lnk2">
      <?php the_date(); ?><br /><?php the_title(); ?><br /><?php the_content(); ?>
    </li>
    <?php endforeach; ?>

    If you just want to link to the post, try this:

    <?php $postslist = get_posts('numberposts=1'); ?>
    <?php foreach ($postslist as $post) : setup_postdata($post); ?>
    <li class="lnk2">
      <?php the_date(); ?><br /><a href="<?php the_permalink();?>"><?php the_title(); ?></a>
    </li>
    <?php endforeach; ?>
    Thread Starter Kevin Kwok

    (@queesy)

    GENIUS! my savor thank your sir! works perfectly =) thank you again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link to newest post?’ is closed to new replies.