How Can i Get 5 Recent Post Title With Corresponding Link?

I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie ….

2 Answers
2

This sounds like an additional Loop on that page, right?
You might want to use:

<ul>
    <?php $posts_query = new WP_Query('posts_per_page=5');
        while ($posts_query->have_posts()) : $posts_query->the_post();
    ?>
    <li><a href="https://wordpress.stackexchange.com/questions/20489/<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; wp_reset_query(); ?>
</ul>

Also read more here:
http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

Leave a Comment