A pretty simple and useful plugin, Page Template Dashboard lets see you what templates your…
There will be times when you want to list out posts from a specific category on a post or page. List Category Posts gives you the ability to list out posts from any category, just about anywhere, in a variety of different ways.
What’s it Do?
Basically, List Category Posts does just what it says. It allows you to list out posts from one or several categories all in one place, on any post or page. The plugin sets you up with a special shortcode with lots of parameters so you can customize the way the posts are output. This includes the ability to add pagination, how much content to show, custom CSS classes, whether or not to show a thumbnail, how posts should be ordered, and a lot more. The plugin also includes a widget which can be used to display category posts in a sidebar, and a built-in template system.
List Category Posts has evolved quite a bit over the years, and more parameters for customization are added all the time. But it’s output is kept very basic so you can make style customizations yourself.
How’s it Work?
After you install and activate the plugin, the easiest way to get started is to use a shortcode in your posts or pages. Just go to the post you want to add a list of category posts too, and use the [catlist] shortcode. You can specify your category using either an ID, name or slug. If you want to specify an ID, you can try:
If you want to use a category name or slug instead, then the shortcode syntax is a bit different. You can actually use the catlist shortcode to get posts from specific authors or tags as well as categories.
If you preview your post, you will see that all of the posts from the category that you selected will be arranged in an unordered list. Each post will simply have it’s name, with a link to the full post. This is the absolutely simplest way to use the List Category Posts plugin. But, the plugin also includes quite a lot of parameters which you can use within your shortcode that can really change the way the posts are displayed. I won’t go into all of them here, but it’s worth taking a look at the full list. For now, let’s just over a few examples.
Let’s say I want something a bit more robust. I’d like to show the featured image from each post, a title and an excerpt. I’d also like to show posts from two separate categories.
[catlist name=my_category+mycategory_2 thumbnail=yes excerpt=yes excerpt_size=30]
This is a bit longer, but basically I am specifying two categories, using the “+” operator to say I want all posts from both of these. I assigned “yes” to the thumbnail and excerpt parameters so that the post is shown along with a small excerpt and it’s featured image. Finally, I added an “excerpt_size” parameter to say that all excerpts should be cut off if they are longer then 30 words.
Next, let’s try adding a list of posts with built in pagination. For my list, I am once again going to specify two categories, and will limit the number of posts shown to 5. I also want to order the posts by title, descending. Once again, I can do this with a few parameters.
[catlist id=12+13 pagination=yes numberposts=5 orderby=title order=desc]
This time, I specified my categories as ID’s. I then switched the “pagination” parameter to yes, and limited the number of posts on each page to 5 with the “numberposts” parameter. Then I set up the ordering of posts.
These are just a couple of examples. There are endless ways for you to combine parameters to get a list to display whatever posts you want. The plugin’s benefit is that it is extremely flexible, and allows you to basically set up a query however you want, wherever you want. Once again, check out the full list of parameters to see all that can be done.
Styling your posts is also fairly simple. By default, the posts are listed in a ul tag with a class of “lcp_catlist” and a unique ID. This might be all you need, and you can simply use this class or ID to set specific styles for the ul and li tags that are listed out. But if you want to get a bit more customization, you can use a few shortcode parameters to add different classes to the plugin’s output. For instance, let’s say I wanted to wrap my title’s in an h3 tag and add a cat_titles class to each one.
[catlist id=123 title_tag=h3 title_class=cat_titles]
Just like that, each title will be wrapped in h3 class=”cat_titles”. You can add a tag or class to just about any part of the output. The full list is:
autor_tag, author_class, catlink_tag, catlink_class, comments_tag, comments_class, date_tag, date_class, date_modified_tag, date_modified_class, excerpt_tag, excerpt_class, morelink_class, thumbnail_class, title_tag, title_class, posts_morelink_class, customfield_tag, customfield_class
If that’s not enough for you, the plugin also comes bundled with a templating system. Again, the details of how to implement this are beyond the scope of this post, but it requires you to create a template file, drag it into your theme folder, and customize however you want. You can then use the “template” parameter to specify which template to use for each specific list. There is a default template included in the plugin folder to help you get started.
The other way to add a list of category posts is to use the included widget. To set that up, visit Appearance -> Widgets and drag the “List Category Posts” widget into any sidebar you have set up. You will see a list of parameters for you to customize it’s output. This list mirrors the list of parameters that can be used with the shortcode, though not all are included. But there are enough to set up the list basically any way you want.
There is quite a bit that can done with list category posts, but its documentation is fairly comprehensive.
Costs, Caveats, Etc.
List Category Posts has been around for a while, with new updates all the time. If you are having a problem with the plugin, you can visit the support forums, or go to GitHub to suggest new features or point out bugs.
- Support Forums
- Plugin Documentation
- Plugin FAQ
- Source Code on GitHub
- Video Tutorial
- Write-up in WP Beginner