Are you a new user at WordPress and struggling to categorize your posts? Or if you’re an old user and trying to advance to the use of coding instead becoming dependent on Plugins?
In either case, you’re at the Right Place!
If you think that your WordPress site lacks organization, then I can help. In this tutorial, I will help you in displaying category posts on a page.
We will cover two methods of doing so by using this article.
Displaying category posts on a page
There are more than one ways of doing so. Both of them can be used to display posts by category, most recent ones coming out on top.
The two methods vary according to their difficulty level, the first one is fairly easier and more simple. Usability of this method for beginners is high as it involves the use of a plugin instead of a code snippet.
But if you’re an advanced user trying to break free of the bounds of a plugin, then skip directly to the second method. Which is for fairly advanced users with a few programming skills. This involves snippets of code that will allow you to display recent posts from specific categories.
The advantage of using the second method is it eliminates dependency on plugins and provides you with greater customization. While on the other hand, the first method is easier and has enough customization features that have been satisfactory for over 90% of the users.
That’s all there’s to both the methods. Let’s now proceed to the actual working of doing so.
Displaying category posts Using Plugin
WordPress Toolkit and Guide
WordPress Resources with all the related guides from Themes and plugins to Monetization. Easy to get and understand!
To start off, the first step is to install Category Posts Widget plugin. For that go to your WordPress Site’s dashboard, Click on Plugins, then go to Add New.
In the new page that opens up, type Category Posts Widget, Install this plugin by clicking on Install Now and then activate it. You know the drill.
After activating it, go to Appearance, under that tab, locate Widgets and click on it.
In the available widgets there, you will see the widget of the newly installed plugin.
When you see the widget of Category Posts, just drag it and drop it to the blog sidebar according to your preference, i.e, wherever you want to see the category Posts bar.
This is what the widget looks like.
The options are pretty easy to understand, with the title, filter, post details, General Settings, and footer. First, to category posts Section you give a title. Then you choose the categories. Followed by multiple display options as shown in the snap.
Post Details includes the images, headings or parts of the posts you want to be displayed etc. After completing the configuration of the widget. Click save and you are done.
The page will be displaying category posts on the sidebar now.
Displaying category posts Using Snippet of Code
This is a Do it yourself (DIY) method for rather advance users, beginner’s please stick to the first step. We will use a snippet of code in this method to display the posts of a category.
I am providing you a snippet of code below.
You need to write this in the functions.php file.
To do that, go to the Appearance tab. Go to Editor.
Here on the extreme right side, you will see the theme files.
Go to functions.php, and copy that code snippet there. Write your own category slug in the place of recent in the code snippet.
This query retrieves ten posts through WordPress from the mentioned category. The posts are then listed bullet wise along with all the post details we have mentioned, including images.
In a nutshell, ‘category posts’, a shortcode was created and enabled in a text widget.
To displays posts by category; do the following.
- Either, paste the code line given below in any of your files in the template (e.g., footer.php).
|<?php wpb_postsbycategory() ?>|
- Or use the shortcode inside the posts or pages. To do so, copy the shortcode and in the content area of the post just simply paste it.
- Or finally, use the shortcode in the widget area. For this, go to Appearance, then go to Widgets. To your sidebar, add a new text widget. After that, in that text widget, add the shortcode. Then save it.
After completing any of these steps, you will be able to view the posts by category.
Since this is not a plugin, you can customize the aesthetics of the list by incorporating CSS to improve the looks.
That’s it, you’re now done!
I hope this helped you show category posts on your page.
If you have any questions I am always here to help. Just drop a comment below. Subscribe for more information.
See you in the Next One! Happy Tech Hunting!Disclaimer: In the name of full transparency, please be aware that this blog post contains affiliate links and any purchases made through such links will result in a small commission for me (at no extra cost for you)