WP Pluggin - List Category Posts
List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, and the number of posts to display. You can use [catlist] as many times as needed with different arguments
My requirement was this.My site has a knowledge base for which a lot of articles are created as posts. All these posts come under the category "articles". I downloaded the plugin, copied it into the wp-content/plugins directory and activated it form admin panel. Then I created a page with title "Articles" (no need to be the same as the category, it was my choice) where I wanted to list all the posts under this category. So I just added this line to the page content:
[catlist name="articles" numberposts=-1 orderby=title]name - category name
numberposts - number of posts to be displayed per page
orderby - sorting order
This worked fine for me as all my posts were within the "article" category, but as soon as I created some posts in another category called "faq" and created a sperate page with shortcode
[catlist name="faq" numberposts=-1 orderby=title] it listed all my post that come under both articles and faq. So I checked back the articles page and now it is also listing all the posts form all categories. So I decided to check the plugin code for the file wp-content/plugins/list-category-posts/list_cat_posts.php. I found out an if condition with a wrong test in list_category_posts() function:if($atts['name']!='default' && $atts['id']!='0') which will never be satisfied as we are giving either category name or category id but not both. So I just changed the "&&" joiner to "||" and everything started working fine. I am going to notify the author of the plugin. But apart from this issue, it is a very nice one. Thanks to him.
You can see this in action here or here
No comments:
Post a Comment