WordPress posts live in your blog feed by default but sometimes you want to display some of your WordPress posts on other pages. This guide teaches a number of ways of how to display WordPress posts on any page.
There are a number of reasons why you would do this. Some of the top reasons are:
- To entice your users to continue browsing your site.
- For better usability of your site by creating internal links.
- Allowing you to create dynamic layouts on your site so they update for you.
Recent posts can be displayed in your sidebar, at the end of your posts, inside your blog posts, in your footer widget areas or literally anywhere else on your site.
How to display WordPress posts on any page
This guide will show you how to manually create a shortcode that will display your most recent blog posts.
You can then use that shortcode to display your recent posts on any page or even in a widget.
Recent Posts widget
WordPress comes with a widget called “Recent Posts”. It is a simple widget that will display your most recent posts in any widgetized sidebar. This is good if you want a basic way to list out your recent posts but is not as flexible as other ways to display posts.
Because the default Recent Posts is quite limited, there are other options. You can install the Recent Posts Widget Extended Plugin.
Display recent posts manually
For those that are a little more adventurous or you simply want to know how its done, then you can manually create code to display your posts.
There are two versions of this code. There is the lightweight version and the fully fledged plugin version.
Each way is using the built-in WP_Query class to get the most recent posts.
The basic way to display recent posts in your theme.
This code can be placed in any location of where you want the recent posts to appear in your WordPress theme.
have_posts() ): $the_query->the_post();
// Display the Post Title with Hyperlink ?>
The advanced way to display recent posts
The second version of this script has some extra options and layouts
We will be creating the shortcode as a very simple plugin that you can install on your own WordPress site.
The code that we will be using is below or you can download the zip file and install the plugin right away.
[purchase_link id=”805″ text=”Download Plugin” price=”0″ style=”button” color=”blue”]
This article should have given you a better understanding on how to display recent posts on any page of your WordPress site. You can display posts on any page in a number of ways and the way that suits you is a matter of opinion and what you need it for.
Let us know in the comments if you need a hand with any of the code mentioned above.