If you want to display posts from specific categories in a page, post, or even a widget, then there’s a simple way to do it.
All you need is a simple plugin called List Category Posts.
Here’s what you need to do.
Step 1
Install the List Category Posts plugin.
Here’s how to install a plugin in WordPress.
Step 2
Go to Settings > List Category Posts to access its options.
You can:
- Choose the numbers of posts you want to be displayed;
- Choose if you want pagination or not;
- Order the posts by:
- Date;
- Modified date;
- Post title;
- Author;
- ID;
- Random.
- Choose ascending or descending order.
Step 3
To quickly and simply display your WordPress posts by category in a page, post, or widget, you’ll have to use this basic shortcode:
[catlist id=23]
Where id
should contain the ID of your category.
Or, you can use this shortcode with the name of your category:
[catlist name="movies"]
Here’s how to add a shortcode in WordPress.
The posts from the category will be displayed as a list.
Adding More Categories
If you want to add more categories, you have two options.
You can use +
(AND) or ,
(OR) between categories.
[catlist id=12+15+3]
[catlist id=16,4,22]
Remember that you can also use the category names instead of the IDs.
[catlist id=movies+sports+news]
If you’re using +
, it will display posts that belong to all of the listed categories, without including children categories.
Here’s more on parent and children categories.
If you’re using ,
, it will show the WordPress posts that belong to all of the listed categories.
Excluding Categories
You can exclude a category using the -
(minus) sign.
[catlist id=4+12-5]
This will exclude the category with the id 5.
If you’re using +
to separate categories, add the categories that you want to exclude last. Otherwise, it won’t work.
[catlist id=23+11+15-10]
Adding More Parameters to the Shortcode
The plugin allows you to display more data for the posts, such as date, author, excerpt, and more.
I recommend checking the documentation to see everything it offers.
Here’s an example.
[catlist id="1" date=yes date_tag=span date_class="my-date" author=yes author_tag=p author_class="my-author"]
Note that for some features, you’ll need to add some built-in CSS classes as well. Otherwise, the posts can look messed up when they’re displayed.
You can find more instructions about that in the plugin’s documentation.
Support the Developer
If you like and use the plugin, consider donating to the developer by clicking on the Donate to this plugin button found at the bottom of the sidebar, in the plugin’s page.
That’s a Wrap
I hope you found this post useful and you managed to display your WordPress posts by category in your page, post, or widget.
If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.
You can also hit the follow button on Twitter and subscribe to the YouTube channel.
Don’t forget to share the post to help out others!
Is it possible to use it for posts tag, products categories, and tag categories?