If you have a blog on WordPress, you might want to display the recent posts on the blog to attract readers to your latest posts. Recent posts can be added to the sidebar or at the end of the post. Basically, there are four methods to show recent posts – plugin, widget, shortcode and manual method. You can choose the method that suits you best. In this article, you will learn all four methods:
1. Using the WordPress recent posts widget
WordPress offers a built-in widget to display recent posts. Simply go the appearance and click on “Widgets”. Add recent posts widget to a sidebar.
Here, you can write an alternate title to the widget, show date and add the number of posts you want to display. Don’t forget to click on the “Save” button to store widget settings.
2. Using Recent Posts Widget Extended Plugin
Default widget functionality is not sufficient. It does not allow you to show thumbnails or excerpts. There are various recent posts plugins available such as Flexible Posts Widget Plugin, Recent Global Posts Widget and Recent Posts Widget Extended Plugin.
First of all, install and activate the Recent Posts Widget Extended Plugin. Go to the appearance and click on “Widgets”.
You can show thumbnails, excerpts, limit categories and tags, ignore sticky posts etc. Recent Posts Widget Extended Plugin offers many options. This widget can be used to display recent posts from any other post type on your site.
3. Using shortcode to display recent posts in WordPress
Adding recent posts in the sidebar is easy. The real question is how to display recent posts inside a WordPress post or page. You can do this by using shortcodes.
The first step is to install and activate the Display Posts Shortcode plugin. It does not provide any settings to configure. Next step is to edit the post or page where you want to display recent posts. The plugin offers a whole range of parameters.
Some examples are given as under:
- To display 5 recent posts with thumbnails and excerpt
- Display recent pages instead of posts
- To display recent pages under a specific parent page
4. Displaying recent posts manually in WordPress Theme Files
Advance WordPress users consider adding recent posts directly in their WordPress theme files. There are many ways to add recent posts directly in WordPress theme files. The easiest way is to use built-in WP_Query class. All you have to do is add the following code where you want to display the recent posts:
For a full list of parameters, you can visit the plugin’s documentation.
This code consists of five most recent posts with their title and excerpt. The WP_Query class offers lots of parameters. It allows you to customize it any way that you like. You can know more about WP_Query class on The Codex.
In case, you want to customize the display of your recent posts without writing code then check out a WordPress plugin called CSS Hero. This plugin helps make design customization easy.
We hope you learned something useful from this article. You can choose any of the above-mentioned methods which seem easy to you. If you have anything to share, add or ask, feel free to drop us a line in the comment section below. We would love to hear from you.