How To Create Custom Post Lists And Display Them Anywhere On Your Blog
I’m not a big fan of standard category pages as an effective method of navigation. Whilst a reverse chronological post order works well for your blog’s home page (as readers will typically want to see your most recent content first), I do not believe that the same can be said for your category pages.
If a reader wants to read more of your content, they should be offered something a little more refined than simply a list of posts that were assigned to a category. What if your most recent post in that category wasn’t particularly stellar? Far better to promote your best content, and leave the bargain basement material where it belongs.
Forget Categories – Think “Resources”
With that in mind, I have always been an exponent of “resource” pages, which are basically category pages v2.0. You provide a little introductory blurb, tell the reader what they can expect, and then provide them with a list of only the best related content. I have such pages on my own blog, but up to now, I had to manually enter my select list of posts. That was until I found List Category Posts – a highly customizable plugin for your WordPress blog.
As you might expect, List Category Posts allows you to insert a list of posts from a particular category, anywhere in your blog – a page, post, or even your sidebar. In posts and pages this is done by including a simple shortcode, such as the following:
List Category Posts provides you with an enormous number of filters and stylistic options that essentially allow you to display any kind of list you could think of, in any manner you could wish for. The full list can be found here, but the following are a selection of my favorites:
- tags – display posts by tag (this parameter can be combined with the category filter)
- orderby – customize the order (e.g. orderby=date, orderby=author)
- numberposts – set the number of posts to be displayed
- excerpt – display the post’s excerpt
- thumbnail – show post thumbnail
This plugin can easily be used to create select lists of your evergreen content. Just use an identifier tag for your best posts in any particular category, then use the following shortcode to display just those posts:
[catlist id=yourcategoryid tags=yourtag]
Hey presto! There’s your resource page. And as long as you remember to tag future content appropriately, it will update automatically.
If there is one thing that lets this plugin down, it is the default formatting. Here is a draft post I created on my blog to demonstrate what the plugin can do:
And here is what the above shortcode produces:
It aint pretty, is it? I was surprised that the default display for the typical title + thumbnail + excerpt display was so jumbled.
In order to get things in order, you can create your own custom template to present your posts in whatever manner you desire (instructions can be found at the very bottom of this page). If you are comfortable with PHP, HTML and CSS, doing so will not be difficult. Here’s what I ended up with:
Much better, right? In order to get the posts to display in the above manner, I used the following shortcode in my blog:
[catlist id=3 numberposts=5 excerpt=yes excerpt_size=330 thumbnail=yes thumbnail_class=cat_list_tn template=custom]
As you can see, I set the number of posts to display as 5, I increased the excerpt size, I defined a class for the thumbnail, and I told the plugin to refer to my custom template.
Then I created my new template file. It was exactly the same as the existing template file, apart from I changed the <ul> and <li> tags into <div> tags. Finally, I added the following to my custom CSS file:
Going through this process comes across a little convoluted when written down (and it is a little bit), but it only took me a few minutes. The plugin could certainly make customizing the formatting of the posts easier, but if I can do it, most people reading this post probably can!
The Options Are Endless…
There are of course a huge number of useful applications for the List Category Posts plugin – I have just touched upon one in particular. You could use the widget to create a list of your favorite posts, or with a bit of PHP jiggery pokery you could create your own related posts section at the bottom of your posts.
I gave List Category Posts a four star rating in the WordPress Plugins Repository as there is still more that it could do, but what it does, it does well.
Creative Commons photo courtesy of jenny downingTags: