Ronald Huereca is part developer, part mammal. And he only comes out at night. View the author's website.
 

WP Categories and Posts

WP Categories and Posts is an extension of the core WordPress function called wp_list_categories. This plugin adds in a template tag you can use to display categories and sub categories and the posts underneath those categories.

For working examples, please see the following pages:

Here is a screenshot as well.

Categories and Posts Screenshot

Download

Please download the file WP Categories and Posts v1.0.

Installation

Installation is simple. Just unzip into your plugins folder and activate the plugin. From there, you may call the function ronalfy_list_categories_and_posts() from within your WordPress page.

An example page template called sitemap.php is included in the zip file. You can copy this file into your themes directory and use it as a page template for your sitemap if you wish.

Usage

The function by itself will return the categories and posts. It will accept most of the same arguments as wp_list_categories, but not all of them. One argument that I noticed that didn’t work was showcount.

Support

This plugin is provided as is, but I will try to answer most of your questions in the comments. Thank you.

Read the Discussion (29 Responses)

  • Bes says...

    http://thereasoner.com

    Excellent job Ronald! :) I will have to use this on my site also.

    Thanks for sharing it with everyone. :)

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    You’re welcome Bes. Let me know if you have any problems with the implementation. It should just be a simple function call and some added styles into your stylesheet.

  • John P. says...

    http://nymisoa.com/blog/

    Clean, simple and extremely useful. Thank you so much!!!

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    John,

    I’m glad you found it useful. Thank you.

  • David Evans says...

    http://onlinedatingpost.com

    This was exactly what I spent hours looking for, but it doesn’t work for me:

    Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 341251 bytes) in

    I shouldn’t have to increase memory allocation.
    Also, how about some documentation and examples?

    I want to create a page and list specific categories, with the titles of each entry linking to the archive page.

    Should be simple, it’s not. Hopefully your plugin can do this.

  • Josette says...

    http://www.booksloveme.com

    Hi there,

    This might be a useful plugin for me but I can’t find the sitemap page anywhere! Can you explain more? Would appreciate it!

    Thanks!

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    David,
    Since this plugin is just an extension of a WordPress template tag, you’ll find the documentation at the WordPress codex site for wp_list_categories. As stated above in the “Usage”, not all of the same arguments will work, however.

    Josette,
    A sample sitemap.php template is included in the zip file. You must copy this file over to your theme directory and set up a new page using this file as a template. You can find more about this at WordPress pages.

  • Josette says...

    http://www.booksloveme.com

    Thanks for replying. Okay, the sitemap.php is in my Themes directory. But I’m not sure how to create a page template.

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    Creating a page:
    In your WP Dashboard, click on “Write”. After that, click on “Write
    Page”. On the right side, there is a thing called “Page Template”.
    There should be a drop down where you can select “Sitemap”. If
    Sitemap isn’t there, it’s possible that the sitemap.php file was
    copied to the wrong theme folder.

    I hope that helped :)

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    Josette,

    I added a link to your sitemap as an example. I hope you don’t mind. If any one else has working examples, I’d be happy to add a few more example links.

    Thanks,

    Ronald

  • Josette says...

    http://www.booksloveme.com

    Wow! Thanks! No problem. I like your plugin and I’m going to write about it in my other blog. =)

  • maxNLO says...

    http://
  • John P. says...

    http://lexhair.wordpress.com

    Still love this plugin. I foresee a day where my site map will be a scrolling nightmare as the months and years go by. Maybe an AJAX implementation which could collapse/expand the index for posts older than a certain date?

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    Hey John,

    That’s a good suggestion. I didn’t really plan on releasing updates to this, but that would be really cool to have. I have a few more projects on the pipeline, but I’ll definitely see what I can do (or can’t do). It may be a while (a few months), so keep in touch.

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    I justed tested this plugin on WP 2.3 RC1 and everything works fine. This plugin should be compatible with the new release.

  • John P. says...

    http://lexhair.wordpress.com

    Ronald..thanks for checking the new RC!

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    John,

    Yeah, to be honest, I’m surprised it still worked :)

  • John P. says...

    http://lexhair.wordpress.com

    With the changes in the database schema, I am afraid several of my plugins, notably EventCalendar3 are not going to survive the upgrade.

  • Andrea says...

    Hi! Is there a parameter to limit the number of post displayed (like the last N posts) ?

    Thanks for your great work!
    Andrea

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    Andrea,

    I have one more plugin to write before I visit this plugin again, but when I do, I’ll be sure to add something like this in.

  • John P. says...

    http://lexhair.wordpress.com

    Ronald…I’m trying to suppress the category name/link and just show the list items of the category. I passed the “title_li=” argument in your function but it didn’t seem to work. Any ideas?

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    John,

    I’m afraid you’re going to have to edit the raw code. If I’m interpreting what you want correctly, you want to change line 126 from this:

    $output .= $parent . "\n<ul>" . $parentPosts . "\n</ul>";

    to this:

    $output .= "\n<ul>" . $parentPosts . "\n</ul>";

    I apologize that there isn’t a more elegant solution.

  • John P. says...

    http://lexhair.wordpress.com

    Nuts. I need the link on my site map but I don’t want it on another template. Thanks for the prompt response!!

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    John,

    I sent you an e-mail last night with a modified version that will allow you to do what you want to do. Hopefully it didn’t end up in your spam box.

  • John P. says...

    http://lexhair.wordpress.com

    Ronald…sweet patch. Does exactly what I was looking for. Props and my thanks!!

  • Mark says...

    Great plugin! How can I stop the date from being shown?

  • lex says...

    http://www.techmonkmarketing.com/

    I would also like to know how to remove the date and how to prevent the main parent category from showing up before each child category.

  • Post Author

    Ronald Huereca says...

    http://www.ronalfy.com

    @lex et al,

    My apologies, but this plugin is no longer updated. Anyone is free to take it over.

  • purose.cn says...

    http://www.purose.cn

    Have a test!
    Thank you!

    It is a great plugin!

Trackbacks (14)

Join the Discussion