
Displaying the recent posts on your website aid users to effortlessly find out your latest content and invest more time on your website. There are a number of ways to add recent posts to your website. You can join the list of your recent posts in your sidebar, following the termination of your post content, within your post content with the help of a shortcode, in the footer widget portion, or anywhere else as per your desire.
This article is aimed at presenting you various different methods to show recent posts in WordPress. We are going to discuss all the related details below. Meanwhile, if you are looking for assistance to display the recent posts on your WordPress page or post, hire WordPress developers from our team and get the best results.
Displaying Recent Posts With The Help Of WordPress’s Built-in Widget
WordPress offers a built-in default widget to show recent posts in the sidebar of your site or any other widget ready area. To achieve this, go to Appearance » Widgets and combine the Recent Posts widget to the sidebar.
The built-in Recent Posts widget does not give a lot of options. It only allows you to give your widget a title, you can select whether you want to display the dates of posts or no, and specify the number of posts you are likely to present.
After performing all the necessities, you are required to click on the ‘Save’ button to
save the settings you have made.
This will make your widget live on the blog.
‘Flexible Post Widget’ Plugin To Display Recent Posts In WordPress
The default recent posts widget’s functionality is very limited and sometimes not enough to display the post in the desired way. Hence, if you are looking for more functionality such as displaying thumbnails, or displaying recent posts of a specific category to display the recent posts, make use of a plugin.
A number of recent posts plugins are available at the present date. Every plugin possesses its own benefits and limitations. Here we are using the ‘Flexible Post Widget’ plugin for demonstration.
For installing a plugin, login to your WordPress admin dashboard. Click on the Plugins -> Add New in the left sidebar and search for the desired plugin. After getting the desired plugin, click on ‘Install Now’ given next to it.
After installing the plugin successfully, search the list of installed plugins, and activate the plugin by clicking the Activate link given with the desired plugin in the list.
Now, go to Appearance -> Widgets with the help of the left sidebar.
Drag your desired plugin to the sidebar of your theme.
Make use of the tremendous options offered by the plugin to display your recent posts as you like.
WordPress ‘Recent Posts Widget Extended’ Plugin
As we have already discussed, the built-in widget offers very limited functionalities and does not even give the facilities like showing thumbnails and excerpts which is oftentimes a preference for users.
However, if you want to show the thumbnails and excerpts with your recent posts and moreover to it, if you want to restrict them to particular sections or tags, there is a plugin called ‘Recent Posts Widget Extended ’ plugin that can help you do achieve the same.
Install and activate the ‘Recent Posts Widget Extended’ plugin following the same steps mentioned above and combine the same to the sidebar.
Recent Posts Extended widget offers a number of options and provides you with a complete check on the approach to showcase the recent posts on the WordPress site. It allows you to display thumbnails, excerpts, check categories and tags, avoid sticky posts, and a lot more. You can even make use of the widget to show recent posts from a different post type on your WordPress site. Leverage the options given by the plugin and display your recent posts as per your wish.
Displaying Recent Posts With The Help Of Shortcode
Combining recent posts to a sidebar is an easier way to display the recent posts to the site. However, sometimes you may need to show the recent posts within a WordPress post or page. The most comfortable way to showcase recent posts in WordPress posts and pages is by employing shortcodes.
You are required to install and activate the Display Posts Shortcode plugin at first to achieve this. It is an amazing plugin without any settings that you need to configure.
Just modify the post or page in which you want to present your recent posts. Then, utilize the shortcode [display-posts] along with your adjusted parameters within the post. The plugin proposes a full range of parameters that can be utilized with the shortcode. Few examples of the same are given below:
To display 5 recent posts with thumbnails and excerpt
[display-posts posts_per_page=”5″ image_size=”thumbnail” include_excerpt=”true”]
To display recent pages instead of posts
[display-posts posts_per_page=”5″ post_type=”page”]
To set the order to title in place of date.
[display-posts posts_per_page=”5″ orderby=”title”]
To display recent pages inside a particular parent page.
[display-posts posts_per_page=”5″ post_type=”page” post_parent=”5″]
These shortcodes can also be utilized within a text widget However, you are required to turn on shortcodes within your text widgets by combining the following code to the functions.php file of your theme or a site specific plugin.
add_filter(‘widget_text’, ‘do_shortcode’);
Building Your Own Display Of Recent Posts
Sometimes, a WordPress user may like to combine recent posts straight in their WordPress theme files. You are required to utilize a child theme to achieve this as this will help you in not losing your changes whenever you update your theme. Always generate a backup prior to editing the theme files.
The most comfortable way to display recent posts manually is to utilize the built-in WP_Query class. Just combine the below code wherever you like to show the recent posts.
<ul>
// Define our WP Query Parameters
<?php $the_query = new WP_Query( ‘posts_per_page=5’ ); ?>
// Start our WP Query
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
// Display the Post Title with Hyperlink
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
// Display the Post Excerpt
<li><?php the_excerpt(__(‘(more…)’)); ?></li>
// Repeat the process and reset once it hits the limit
<?php
endwhile;
wp_reset_postdata();
?>
</ul>
The above code displays the five most latest posts along with their title and excerpt. The WP_Query class possesses a number of parameters that enable you to customize it as per your choice.
Hope the above explanation will be a great help for you to know how to display the recent posts in WordPress.
Need more assistance? Hire our WordPress developers immediately and get the best help!