ClockWorkBlogger » Page 'Sobek`s Posts in Category plugin'

Sobek`s Posts in Category plugin

Sobek`s Posts in Category plugin is a WordPress 1.5+ plugin (works well with everything above version 1.5), which displays a list of the posts from one or more categories in virtually any way you want.


  • Very small
  • Easy to use
  • Extremely flexible

What can you do with it?

  • Display a list of the posts from one or more categories as joint or seperate lists
  • Use the plugin multiple times in your pages, posts, header, footer, sidebar
  • Limit the number of posts displayed
  • Put the result on show as ordered, unordered or comma-separated list 
  • Sort the output by post title, date or number of comments
  • Show the number of posts that were listed
  • Present the number of comments for each post
  • Display the date of posting for each entry listed 
  • Inform which author wrote each post


  • WordPress 2.3 or above
  • Exec-PHP plugin or similar to be able to make php calls within pages or posts.


Version history

  • v1.9 (November 11th, 2007) – display the date of publishing a post, changes in syntax
  • v1.8 (November 7th, 2007) – limit the number of posts displayed
  • v1.7 (November 4th, 2007) – put the result on show as ordered, unordered or comma-separated list
  • v1.6 (November 1st, 2007) – inform which author wrote a post
  • v1.5 (October 29th, 2007) – improves display speed and adds support for sorting posts by number of comments
  • v1.4 (October 26th, 2007) – lets you output the number of comments after the link to a post, also the order of arguments supplied doesn’t matter now
  • v1.3 (October 23rd, 2007) – now with the option to display how many posts you have listed with one call
  • v1.2 (October 20th, 2007) – adds sorting by title or date and a small rename of the function
  • v1.1 (October 17th, 2007) – features listing several categories with one call
  • v1.0 (October 14th, 2007) – basic working version

Bugs fixed

  • v1.9

    - it’s not really a bugfix, but here goes: (hopefully) fixed Front Page Excluded Categories from limiting the display of posts on the main page when using Sobek’s Posts in Category

  • v1.6

    - the post count stopped being enclosed by <li> tags, since it would cause problems when the list is displayed within <ol> tags (i.e. it spoofed the numbering of an ordered list)

  • v1.5

    - fixed problem where more than one argument would make the function behave improperly

    - fixed problem with handling a non-standard wordpress installation (i.e. with a prefix other than “wp_”)


  1. unzip downloaded file
  2. upload sobeks_posts_in_category.php to your “wp-content/plugins” folder
  3. enable the plugin on the “Plugins” tab in your administration area

Basic usage

PS. You may also want to read the tutorial I wrote for the plugin.

  1. enter

    <?php sobeks_posts_in_category(xyz) ; ?>

    anywhere on your page you want the list of posts to be displayed

  2. replace “xyz” with the number of the category the posts you want to display belong to eg.

    <?php sobeks_posts_in_category(16) ; ?>

    to list more than one category at once replace xyz with a comma separated list of categories eg.

    <?php sobeks_posts_in_category(16,32,8) ; ?>

  3. enclose the function call with “<ul>” and “</ul>” eg.

    <ul><?php sobeks_posts_in_category(16) ; ?></ul>

  4. Repeat steps 1-3 for as many categories you want

Advanced usage

Sobek`s Posts in Category plugin currently supports the following tags. If you choose not to use them, a built-in default value will be used in their place (i.e. nothing will break):

  1. sort:title” / sort:date” / sort:comments” – sorts the output by title, date or number of comments. Defaults to “title” eg.


    will produce the same result as


    whereas this call will produce the same list of posts sorted by date:


    and this call yet again the same posts, this time sorted by “most commented”:


  2. “author” – shows the author of the post eg.


    will not show the author of the post, whereas


    will produce the same list with the author information displayed.

  3. “postcount” - shows the number of posts displayed in one call eg.


    will not show how many posts were listed, whereas


    will produce the same list with info about how many posts you displayed.

  4. “commentcount” – shows the number of comments to a post eg.


    will not show how many comments a post has, whereas


    will display the same list with the number of comments shown.

  5. “style:order” / “style:unorder” / “style:comma” – displays the output as ordered, unordered or comma-separated list. Defaults to a backwards compatible form as shown in “Basic Usage” eg.


    will result in an unordered list i.e. by default you have to provide the <ul> or <ol> tags yourself. If you use “style:order” / “style:unorder” / “style:comma” as argument the script will produce the <ul> or <ol> tags e.g.


    will display an ordered list of the contents of categories 16 and 32 with all <ul> and <li> already supplied.

    PS. The comma-separated list has no <ul>, <li> or <ol> tags.

  6. “limit:{x}” – limits the number of posts displayed to {x} eg.


    will display all posts of categories 16 and 32 as one ordered list. If you use the limit argument only the first {x} posts will be displayed e.g.


    will show the first five posts from a combined list of both categories.

    PS. The brackets in “limit:{x}” are only there to make the “x” stand out. Limiting the number of posts to be displayed is generally used to show e.g.

    • a list of 5 recent posts from category #4 e.g.


    • a list of the 10 most commented posts from categories #5 and #6 e.g.



  • The sitemap of this page here (sorted by title or date with comments counted)

CSS Styling

To style the output of the list just assign a class or ID to the “<ul>” tag eg.

<ul class=”helpful”><?php sobeks_posts_in_category(16) ; ?></ul>

and modify your wordpress css file to style the entries of the list.

If you used the “orderlist” / “unorderlist” parameter the class of the container is called “sobeks_pic“, so if you want to style your list enter something like

ul.sobeks_pic {

ul.sobeks_pic li {
    border-bottom: 1px solid #eee;

into your style.css


  • WordPress Category Posts Plugin by Brian Groce for WordPress versions prior to 2.3. (presents the same functionality as v1.0 of Sobek`s Post in Category plugin)

119 comments to “Sobek`s Posts in Category plugin”

Like my work?


Leave a comment