Herself’s Webtools

Webtools for Webmasters: Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Herself’s Webtools header image 1

Here is a Wordpress plugin to create a link list of all posts in one category

October 12th, 2007 · 27 Comments

This plugin is for Wordpress version 2.3+. Plugin and directions for WP before 2.3

== Description ==
This will create a list of all your posts in one specific category. They will be ordered alphabetically by category.
You can put this as a list in your side bar.

== Installation ==

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

2) In the Admin page find Options->Posts by Category and put in the number of the category you wish to list and click ‘Update Options’

3) Add the following code to your sidebar:

OR

3) Add the following code to a page or post

<!– categoryofposts –>

WP Plugin: Creates Link list of posts for a specific category

You can see this in action by visiting the archives link on this page or my TimesToCome, TimesToCome mobile, houseplants, or Houston Garden site.

** Note (Dec 12th)  I just widgetized this for those of you who prefer widgets. TimesToCome Category of Posts Wordpress sidebar widget

Tags: archives · wordpress

27 responses so far ↓

  • 1 admin // Oct 25, 2007 at 2:35 pm

    10/25 I upgraded this blog to WP 2.3 today and discovered a flaw in the MySQL for this plugin. It’s fixed - new version is at WP and on side bar. This is the plugin that is listing the ‘How To’ list of links to your right.

  • 2 WordPress Plugins Database » Plugin Details » Category of Posts // Oct 26, 2007 at 1:15 am

    [...] Visit [...]

  • 3 squarehippies // Jan 9, 2008 at 11:25 pm

    Hi, I have installed the plugin and activated it (after a few unsuccessful activation). I’d like to put the code inside a page, so I created a new page, switch to code view and copy paste your code:

    and publish. Nothing appeared. What did I do wrong? Thanks!

  • 4 admin // Jan 10, 2008 at 7:57 am

    Ok, Now that I’ve had some coffee I can see the problem.

    This works in your template - not as a page. WP limits what you can do and not do with php inside posts and pages. You can however customize an archive page See the directions here for creating a customized archive page for the other plugin. Replace archives_by_category() with category_of_posts() and it will work just fine.

  • 5 websta // Jan 19, 2008 at 3:50 am

    Thank you for creating your plugins. I was able to install your Archives by Category plugin and have it work well within a “Page”: http://wisdomofthejedi.com/?page_id=220

    I have also had some success with the Category of Posts plugin:
    http://wisdomofthejedi.com/?page_id=221

    I see your notes above but am unsure exactly what you are suggesting we replace “archives_by_category()” with “category_of_posts()”? …In the post/Page? Within the plugin itself? What does this accomplish? As you can see, I have the two plugins working within Pages in 2.3 (and without have the Exec-PHP plugin installed).

    My major question is if there is a way to use the plugin for several categories at once?? I tried varying the code, but am no expert at PHP and wasn’t able to do so without conflicts arising, insomuch that WP wouldn’t install the different variations at once. Can you help?

    Also, FWIW, I noticed there are some references to specific CSS classes within the code, e.g., “updated fade”, “options”, & “wrap”.

    Thanks again for your great plugins!

  • 6 admin // Jan 19, 2008 at 8:45 am

    Not yet. I may work on that though.

    To use multiple categories, you can either change the MySQL statement that does the select. That will include several categories of posts in one list.

    Or make copies of the plugin - give it different names and make sure all the functions have different names if you wish to keep them separate. Use find and replace to be sure you catch all references to the function names.

    But I was wondering what to start working on next week so perhaps that is a good project.

    If you want more specific info on hacking the plugin leave a comment here and I’ll post more detailed information for you and anyone else who is interested.

  • 7 Confused // Jan 19, 2008 at 10:44 am

    Hey,
    Nice plugin, however at first it didn’t work. Then i must have done something as it now displays all the posts in the category i told it too like its meant to do after giving me an error message.

    I do have Exec-PHP installed.

    But considering it seems to be working now i was wondering if you could make the edit requested by the other user websta as i would like to have different pages displaying all the posts alphabetically of one category.

    I’ve attempted to chang teh functions with the little knowledge of PHP coding i have and it makes my installation unuseable until i deactivate it.

    So could you please make these edits for multiple pages as it would be greatly appreciated :)

  • 8 admin // Jan 19, 2008 at 10:51 am

    OK, This month and next are really, really busy but I think I can get that done this week, next at the latest.

    So I can write it so that several categories show in one list. ( easy )

    Or you can use it in one sidebar to list several categories separately each with a separate heading ( a little more difficult )

    And I can do two plugins with different names that do the same thing, say a left and a right sidebar version. Same plugin but will allow you to run it twice in the same sidebar or separately in the same sidebar.

    I will get all three versions done, first two I’ll likely do as updates to the current version and post to WP pages. Left and Right version I will just add to this site.

    I’ll leave a note in the comments section here when they are complete along with a link. They may not show on the WP site or as a separate blog entry until much later.

  • 9 Confused // Jan 19, 2008 at 2:18 pm

    The third update you listed might do the trick.

    What i meant in my last comment was:

    One Page: Lists say category 2
    Another Page: Lists say category 3
    Another Page: Lists say category 4 etc…

    Do you understand what I mean?

  • 10 admin // Jan 19, 2008 at 2:49 pm

    Sorry I hadn’t had my coffee yet. I was thinking of a different plugin.

    I do understand. Give me a bit, I need to think about the right way to do that.

  • 11 admin // Jan 19, 2008 at 4:51 pm

    OK, I have a plan. Should have things working and instructions up this weekend.

  • 12 admin // Jan 19, 2008 at 5:27 pm

    OK. I wish there was an easier solution, but if there is I do not know it.

    I re-wrote the plugin so you can feed it one category number at a time. The bad part is you have to create a separate archives page for each category. And remember to do so every time you create a new category. There is no way I am aware of to have WP do this for you.

    I have a gzip file with the plugin, detailed directions are in the plugin and I set up an example using the ‘default’ theme that comes with WP.

    You will have to create the archive pages for the particular theme you are using and upload and activate the plugin.

    Do not upload and overwrite your default WP theme. I just did this to make it easier for you to see what needs to be done.

    Archives by category pages, examples and plugin

  • 13 websta // Jan 19, 2008 at 6:12 pm

    Below are my suggestions to adapt the Category of Posts plugin to accommodate separate listings of different categories in different locations. This functionality is very important if you are using Wordpress as a simple-yet-powerful CMS (Content Management System).

    Note: If you only want a single list of links to all posts/Pages from a single category on your entire blog/site, these suggestions are not needed; just follow the Category of Posts plugin’s instructions. If you want a single listing with links drawn from *all* categories, then you need the Archives by Category plugin also available here from Herself’s Webtools.

    Thanks again to Linda for the great plugins! I have also been working on this today, and only now see that she has already posted here changes, which may invalidate the instructions below. Oh well, FWIW…

    For the instructions below, I will use an arrow like this: ==> to distinguish between the original “before” and the suggested “after.”

    Step 1. Open categoryofposts.php in a text editor.

    Step 2. Customize the Plugin Name to keep this version of the plugin straight:

    - at Line 3: Plugin Name: Category of Posts ==> Plugin Name: Category of Posts for 3 Jedi Sayings

    Step 3. Enter the cateogory you want to offer a list of links for all the entries in that category:

    - at Line 13: add_option(’category_number’, ”); ==> add_option(’category_number’, ‘3′);

    Step 4. The following changes all make the various functions of the plugin unique, so they do not conflict with the other versions you have installed for other category link lists. I suggest simply adding the category’s number for the sake of clarity and to keep things consistent, in this case, for category 3:

    - at Line 16: function pc_add_option_pages() { ==> function pc_add_option_pages3() {

    - at Line 23: function pc_options_page() { ==> function pc_options_page3() {

    - at Line 65: function category_of_posts() { ==> function category_of_posts3() {

    - at Line 113: function pc_generate($content) { ==> function pc_generate3($content) {

    - at Line 114 (note two changes): $content = str_replace(”“, category_of_posts(), $content); ==> $content = str_replace(”“, category_of_posts3(), $content);

    - at Line 118: add_filter(’the_content’, ‘pc_generate’); ==> add_filter(’the_content’, ‘pc_generate3′);

    Step 4. Save the file under a different name, for example, categoryofposts3.php.

    Step 5. Activate the plugin in the WP admin area “Plugins.” (If an error appears which prevents the plugin from installing, then double-check if all changes indicated above were made consistently and that you aren’t doubling up numbers between plugins. Also, check the error message carefully for it’s suggestion as to the approximate location of the error.)

    Step 6. Click “Write,” select either to write a post or “Page,” and click the “Code” tab.

    Step 7. Enter: <!– categoryofposts3 –>

    Note that the 3 in the example above should be replaced with the number you chose above. You may enter text or images above or below the code above, just be sure you do not disrupt the strip of code. Note that the Exec-PHP plugin does not appear to be needed for this plugin to operate properly.

    Finally, “Save” and “Post” the post/Page as you wish.

  • 14 websta // Jan 19, 2008 at 6:19 pm

    Linda, in Step 7 above the:

    (less than arrow)!– categoryofposts3 –(greater than arrow)

    is not appearing properly after the word “Enter:”. Thanks for your help and attention on this plugin. Appreciate it!

  • 15 admin // Jan 19, 2008 at 6:28 pm

    Cool! Thanks.

    So which ever solution works for you all use.

    I fixed step 7 for you, the WP comment area is strict in what it allows I had to use the &..; symbols in place of typed arrows.

    If want to email me at the ‘Contact me’ below your version I’ll host it here. Be sure to put your website or email so people can contact you with questions.

    Or put a link to your website if you have it there, or not as it pleases you. Matters not.

  • 16 Confused // Jan 26, 2008 at 12:15 pm

    Sorry , That i haven’t given you two feedback in a while. I’ve just checked back as i’ve been busy lately and didn’t have much time for web development.

    I can see how much effort both of you have put into this and the instructions.

    I’ll have a go at implementing these and post back here.

    Thanks again.

  • 17 Confused // Jan 26, 2008 at 12:47 pm

    On step 7 there might have to be a double dash instead of a single as the original plugin is like that.

    However i’ve installed it fine but it shows the posts in the category that is set to the original plugin. Do i have to unistall the original for it to work?

  • 18 Confused // Jan 26, 2008 at 1:11 pm

    I tried deactivating the original plugin and the posts in the original lugins set category was still shown.

  • 19 admin // Jan 26, 2008 at 3:34 pm

    Download the file in the previous comment I made. ( #13 )

    Unpack it. You will find a new plugin plus an example template with several archive pages one to a category.

    Upload and install that plugin and just copy what I did to make several archive pages. You’re template will be different than mine so that part you have to do yourself.

    The examples and the directions should be easy to follow. I’m using it now on my recipes page to put several sorted categories of links in the sidebars of my Recipes site. I just switched it over this morning. You can use the new plugin to put lists in sidebars or to make archive pages.

  • 20 Confused // Jan 26, 2008 at 7:42 pm

    Thanks, I’ll implement the plugin and let you know how it goes.

    I’d like to thankyou again for all the help you’ve given and the quick response time. I’ll certainly be making trackbacks to a number of your articles in the future when my site is finally setup.

    Regards

  • 21 admin // Jan 27, 2008 at 8:58 am

    You’re welcome and be sure to let us know when your site is up so we can go visit you.

  • 22 Confused // Feb 2, 2008 at 9:27 am

    Hey again,
    I’m extremely glad to say it works like a charm :) I can’t thankyou enough for this.

    When i’m done with tweaking my site i’ll post the link.

    Thanks again,
    Confused

  • 23 admin // Feb 3, 2008 at 8:52 am

    You’re welcome!

  • 24 crazyoval // Feb 27, 2008 at 4:30 pm

    HI, can this work somehow across subdomains? as in, I have a number of categories that I would like to have as prefixes to my main domain e.g.

    category1.mydomain.com
    category2.mydomain.com

    Is there a way to set this plugin out in a way that can make this happen?

    Many thanks

  • 25 herself // Feb 27, 2008 at 11:27 pm

    I don’t know, but I see no reason it would not.

    I’m out of town this week, so it’ll be late next week before I can play with it.

    Try it and see.

  • 26 clevercleaver // Mar 11, 2008 at 9:35 am

    Looks like a cool plug in- how can I use this to list all posts in a category in the main body of a specific page, though? Is it easier than I think?

  • 27 herself // Mar 11, 2008 at 11:48 am

    Yes it will work in a page as well as your sidebar. It will not, however, work in a post.

You must log in to post a comment.