WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Apr 06 2010

How to Call the Title(s) of Your Most Recent Blog Posts

Probably the easiest way (at least that I've found so there probably is a much easier way native to WordPress) is to get the Recent Post plugin By Nick Momrik, which allows for the PHP call

[php]<code><?php mdv_recent_posts(); ?>[/php]

in your posts or templates. It also can be expanded to include other paramaters. For example,

[php]<?php mdv_recent_posts(1, '', '<br />', true, 0, true, false); ?>[/php]

The parameters:

  • $no_posts (#)- sets the number of recent posts to display
  • $before ('HTML Code')- text to be displayed before the link to the recent post (needs single quotes around the text)
  • $after (HTML Code')- text to be displayed after the link to the recent post (needs single quotes around the text)
  • $hide_pass_post (true/false)- whether or not to display password protected posts
  • $skip_posts (#)- allows skipping of a number of posts before showing the number of posts specified with the $no_posts parameter
  • $show_excerpts (true/false) - allows the post excerpt to be output after the post title
  • $include_pages (true/false)- allows recent pages to be show with recent posts

So,

[php] <?php mdv_recent_posts($no_posts, $before, $after, $hide_pass_post, $skip_posts, $show_excerpts, $include_pages); ?> [/php]

Now, if you wish to use this in one of your blog posts or sidebar widget as I did on one of my sites, you will need another plugin to allow you to use PHP code in your Visual/HTML editor (though the Visual part will have to be disabled) or in your sidebar. Two really good ones are:

  • Exec-PHP, requires the visual editor to be turned off (though it can be worked around if you are willing to lose your code if you accidentally switch to the Visual Editor). What would make this a most excellent plugin would be if you could turn off the visual editor only on certain, specific posts and not just everyone.
  • Executable PHP Widget, which is like the Text Widget but allows PHP.

Written by Travis Smith · Categorized: Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in