Title: Get Post Titles
Last modified: August 21, 2016

---

# Get Post Titles

 *  Resolved [cromermusic](https://wordpress.org/support/users/cromermusic/)
 * (@cromermusic)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/get-post-titles/)
 * I’ve tried over and over with different things but I can’t figure it out. What
   I wan’t to to is to show 5 post titles and that’s it. The documentation on how
   to write this code is very poor to say the least.
 *     ```
       <?php query_posts('showposts=5'); ?>
       <?php if (have_posts()) : ?>
   
       <?php while (have_posts()) : the_post(); ?>
   
       <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
   
       <?php endwhile; ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Dave Naylor](https://wordpress.org/support/users/wpranger/)
 * (@wpranger)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/get-post-titles/#post-4732968)
 * You’re missing this at the end:
 * `<?php endif; ?>`
 *  Thread Starter [cromermusic](https://wordpress.org/support/users/cromermusic/)
 * (@cromermusic)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/get-post-titles/#post-4732969)
 * ahh that did the trick! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get Post Titles’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [cromermusic](https://wordpress.org/support/users/cromermusic/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/get-post-titles/#post-4732969)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
