Herself's Webtools

Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Here is a plugin to print a list of all your posts by category in Wordpress

with 14 comments

Over time all your posts get buried. If someone visits your blog can that person easily find a post she is looking for? Can someone find a post related to one he is viewing? Wordpress archive pages give you a list of categories and a list of months but no direct links to your posts. You know what they say, 3 clicks and your visitor is gone.

So I wanted an archive that listed all my posts, by category, alphabetically by title. So I started with Frucomerci’s ‘List Posts by Category Plugin for Wordpress and shamelessly hacked his plugin.

The new plugin ArchiveByCategory lists all your published blog posts by category alphabetically.

Download, unzip, upload to your plugin directory and active the plugin.

Oct 17th —————————————————————————–

Ok I’ve been told you’all don’t like hacking your templates. So you can just create a post or page; click the ‘code’ button an add the following line

<!– archivesbycategory –>

Braver folks can follow directions below to hack your template

* thank Rob at Backyard Chickens for letting me know you wanted this.

—————————————————————————————-

Now an archive page is needed. Next you need to hack your template. Open up ‘archives.php’ [ not archive.php ] and find the line

<?php wp_list_categories(‘title=0′); ?>

Yours might be slightly different. Remove that line and put in its place:

<?php echo archives_by_category(); ?>

Now all you have to do is create a page – call it ‘Archives’ and select ‘Archives’ as the page template. Nothing else needs to be done but to ‘publish’ the page.

I’ve built in anchor links to the page. It will get very long over time. You will want to create anchor links to each category. ( See How and why you should use anchor links ).

The archives page will update itself with all your news posts as you publish them. Nothing more need be done once this has been set up.

[ check sidebar for newest versions ]
*If you are using Wordpress 2.3 download the ArchivesByCategory V 2.2 I totally cleaned up the MySQL and php and it is easier to read, for you to configure and should run a little faster.

*If you are using an earlier Wordpress version you need ArchivesByCategory V 1.0

If you just want to list one category of posts see:
Plugin to list one category of posts ( WP < 2.3 )
Plugin to create a list of posts for one category ( WP>2.3 )

Written by timestocome

October 1st, 2007 at 5:00 am

14 Responses to 'Here is a plugin to print a list of all your posts by category in Wordpress'

Subscribe to comments with RSS or TrackBack to 'Here is a plugin to print a list of all your posts by category in Wordpress'.

  1. I’m not able to make this work in WP 2.3, – as far as I can see is that this line causes all the troubles:
    $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND ID IN (Select post_id FROM $wpdb->post2cat WHERE category_id =$posts->cat_ID) ORDER BY post_title ASC"); as it uses the old db tables to WP, but I’m not mySQL guru so I’m not sure where to go to fix it.

    And I also get an error on blogs where I don’t use the prefix wp_ : however I found that replacing wp_ with $$wpdb-> did the trick.

    Kristin

    2 Oct 07 at 5:04 am

  2. Thank you. I am stuck at the ER with dh. I will fix this and post an update after I get home and catch some sleep. Look for it around dinner or early evening.

    admin

    2 Oct 07 at 10:03 am

  3. OK, I have V2.1 here, link on side bar. I’ve uploaded it to the WP plugin repository as well.

    V2.1 will handle tables that do not begin with the default wp_

    Also somehow the file V2.0 overwrote or got mixed up with V1.0 a clean version is on the side bar. That line does not belong in version 2.0

    The clean version is up at the WordPress plugins site as well. All should be well.

    It is going to be a hectic week here. If you have any questions or troubles, post a note here and I’ll get to it as soon as I can

    admin

    2 Oct 07 at 1:34 pm

  4. Sorry, I didn’t get back right away, seems like I have a busy week myself..
    Anyway, your new version (2.1) worked, I just had to insert one line to make sure only categories (and not tags) was shown – right over and post_status = 'publish':

    and taxonomy = 'category'

    And I just want to thank your for a great plugin :)

    Kristin

    8 Oct 07 at 2:47 am

  5. Thank you!

    I have 2.3 on my home machine but have some more plugins to write before I convert my online blogs. So I haven’t any tags and totally missed that.

    I’ll fix that, probably Wed., sooner if time allows. I’m hoping to get the rest of what I need written this week and upgrade the blogs next weekend.

    admin

    8 Oct 07 at 10:00 am

  6. OK Version 2.2 will not show tags, just categories. I made the changes you suggested and they worked beautifully.

    I’m having trouble with svn but as soon as I figure that out it’ll be at WP plugin repository. In the meantime you can download it from the left sidebar link.

    admin

    10 Oct 07 at 12:23 pm

  7. As suggested to me both versions have been updated so you can just add
    to a page or post ( in the code section) rather than hack your template.

    I should have the new versions uploaded to WP after a brief battle with Subversion.

    admin

    17 Oct 07 at 12:34 pm

  8. Is it possible to remove one of the categories from the list?

    teacherparentresources

    7 Mar 08 at 8:42 am

  9. No, and I needed that also. So I wrote a plugin that lets you list each category separately. You can use it to build archive pages or list each category in a side bar. I’m using it on my recipe page. Instructions and download are here

    herself

    7 Mar 08 at 9:22 am

  10. Thanks, this plugin seems just exactly what i need. However, i can’t figure out your instruction to ‘Now all you have to do is create a page – call it ‘Archives’ and select ‘Archives’ as the page template.’

    How can i select ‘Archives’ as a page template?

    I have the feeling that this might be very simple, so sorry if this is a stoopid question… :)

    doesje

    30 May 08 at 4:08 am

  11. Ok, found it. ‘NOTE: In order to access the Page Template selector, there must be at least one custom Page Template available in the active theme’.

    Grrr.

    doesje

    30 May 08 at 5:27 am

  12. Ouch, sorry about that, I guess I had always by sheer dumb luck had some in there.

    Thanks for letting people know.

    ljmacphee

    30 May 08 at 8:13 am

  13. Just the plugin I was looking for as I would like to display post/page entries on one page in each category rather than in the sidebar.
    New to Wordpress and I cannot find archives.php. My theme editor lists templates but none called archives.php. Does this mean I have to create this template from scratch?
    What do I do next as I would really like to implement this template for ease of navigation to each and every post/page in each category.
    Peter

    inettopic

    8 Nov 08 at 2:40 pm

  14. If there is a single_page.pdf file that works, or if not just remove most of the post stuff from the index.pdf page. ( be sure to work on a copy! )

    Once you have an archive page for each category it will update itself.

    I just keep a link list to the archive pages in my sidebar so people can find them easily.

    ljmacphee

    8 Nov 08 at 6:53 pm

Leave a Reply

You must be logged in to post a comment.