March 23, 2019

WordPress Category Posts Plugin v1.0

I needed to create a nice, simple list of all posts in a single category and couldn’t find any WordPress plugins to do what I needed, so I created the WordPress Category Posts v1.0 Plugin.

Check it out and if you see anything that looks like a bug, have any questions or the documentation needs corrected, please let me know.

[Note: This has been updated.]

Comments

  1. woohoo. I don’t have to figure this out from scratch! Thank you!

    So, an additional parameter I’d like to see is number of posts to display. I’d like to see the X most recent posts w/ a given catID. I suspect this is trivial, but I haven’t figured out how to do it yet, so I thought I’d make the suggestion.

  2. double woohoo.. A quick look at the database description for wp and…

    I modified the ORDER statement to read

    $get_posts_in_cat .= “ORDER BY $wpdb->posts.post_date DESC “;

    and added this after the order statement.

    $get_posts_in_cat .= “LIMIT 10”;

  3. Does anyone know how to tweak this so that the posting date appears with the link? I’ve tried, but I suspect my ignorance of the “echo” command is ultimately causing all the errors, after I add varous combos, trying to get to the desired goal. Thanks!

  4. how to use this script??
    where to put it?
    the readme is not clear..i’m a newbie in wordpress…
    please explain step by step example how to use this…

  5. great little plugin – i’ve been trying to wrap my brain around this all day – i needed to display 5 posts + short extract from one category arranged by date on the front page. Got stuck on this point so thanks LOTS!

    wonder if anyone else needs the extension, then i’ll put up the code.

  6. I need to show the excerpt of the post, but I don’t know how! Could anybody help me?

  7. Add this to your select…

    $wpdb->posts.post_excerpt ,

    Add this to your loop…

    $post_excerpt = $posts_in_cat_row[‘post_excerpt’];

    And echo $post_excerpt where desired.

  8. I am totally blown away by your WP Category Posts plug in and the level of support you provide. It’s fantastic and thank you for making such an easy to use feature.

    I was wondering if you could tell me how to rescrict the number of posts being displayed.

    Thanks again for your help and keep up the good work.

  9. Oops I forgot to mention that it is the first number of entires I need. Many thanks for your help.

  10. $get_posts_in_cat .= “LIMIT 10″; works perfect for limiting, but I have no way of making the most recent posts display.

    $get_posts_in_cat .= “ORDER BY $wpdb->posts.post_date DESC “; generates errors.

  11. Hi,

    This is really a useful plugin. I was surprised not to find it in the core WP code.

    I was wondering if it is possible to show only specific posts from a specific category?

    Thanks a lot,
    Mohib

  12. This is a great plugin – should definately be included in the standard WordPress distribution !

    I have one small problem though, which only appears when WP Cat Posts is generating the displayed page… so i though the error might lie with the plugin:

    Please have a look at http://www.aficionado.dk/
    Place mouse cursor over the ‘cigarer’ category. – The ‘on-mouse-over’ displays the text ‘Anmeldelser af cigarer’ – this is ok!

    But try to enter the ‘cigarer’ category .. now the ‘on-mouse-over’ suddenly displays Anmeldelser af cigarer – which looks silly.

    Please forgive me for being a complete newbie when it comes to messing around in php codes, i’ve learned a little, but unfortunately not enough to solve this – i hope you can help me.

  13. Perywinkle says:

    Did any one notice that the 1st post in the category is skipped?

    Also I am wondering how to wrap this in a ul / li

  14. Great plugin, I agree with some of the other comments, this functionality should be in WP core. I have a few suggestions that might make it better.
    Option to sort links by date, title, etc
    Option to limit number of posts
    Option to display category title as a link

    If anyone knows how to do these, please let me know. I am not doing very good at learning PHP.

  15. I’d like to know how you can wrap the result in a too if anyone can give me a hint… by the way, this is a very handy little plugin.

  16. Yes, how do you space out each link, as with and ?
    And what did the poster Michael mean when this won’t display recent posts? It doesn’t?

  17. if you edit the .php file at the echo command, stick a <li> at the beginning of the string and a </li> at the end of the string, both just within the single quotes. then, edit the sidebar in the theme editor, putting the <ul> tags around the <?php wp_cat_posts(3); ?>

  18. Hi! Will you plug-in enable me to list the posts under the categories in the sidebar?

    Thanks,
    keith

  19. Many thanks for this plugin – it’s sorted out an issue that has been driving me nuts. All the other solutions I’ve tried have fallen over when a post is in more than one category.

    I found that $cat always gave me the correct ID for which ever category page I was on. So I added it to in place of the static number (3).

    Hey presto – I put the above code in sidebar.php and it works like a dream. I get the (correct) list of posts for whichever category page I’m in and it’s 100% automatic.

    Very cool – Big Thks!

  20. I added the select, the loop and the echo $post_excerpt … not working … i am using wordpress 2.0 … and it looks like this …
    echo ‘‘ . $post_title . ‘‘;
    echo $post_excerpt;

    whot did i do wrong ? … PS … I suck at PHP … please advise

  21. Hi,

    How do I include the date below the title?

  22. Hi,
    The plugin looks fine, but I can’t find any information on how to use it… pleeease heeelppp. What I need is to have the title of the category above the list of related posts. Is it the proper plugin to do that ?
    Thank you,
    Gerald

  23. Hi Brian,

    Great plugin by the way – very useful indeed. Quick request though – can you think of a way of assigning a class or an ID to the current post in the list? I would like to highlight this if possible so if your plugin can handle this that would be great.

    Cheers
    Matt

  24. Hi. I found this plugin in the comments of an OnLamp article. However, out of the box, it didn’t do what I needed for my project. Therefore I wrote my own Posts for Category plugin. I hope it proves useful to others just as it did to me. Your work in this plugin no doubt helped me so thanks.

  25. I wanted to show a list of the posts from the same categoy of the post the user is reading. Sounds simple – but after a day of following all of the ridiculous advice from the wordpress forums (none of which mentioned this plug-in that I came across!), I stumbled across this and VOILA! It is perfect for my needs – once I put the $cat as the variable. Thank you!!

  26. please, can you tell me how to use this plugin with “my post icons” plugin ?

  27. Thank you for this plugin, which seems to be working fine in 2.1. My only request would be to be able to add the date a post was posted. How would this be done?

  28. I just tried the excerpt coding you have written here Brian and it will not show the excerpt in the brand new wordpress version. Do you know if its compatible or not? Here is the code I used:

    posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_excerpt ,”;
    $get_posts_in_cat .= “$wpdb->post2cat.post_id, $wpdb->post2cat.category_id “;
    $get_posts_in_cat .= “FROM $wpdb->posts, $wpdb->post2cat “;
    $get_posts_in_cat .= “WHERE $wpdb->posts.ID = $wpdb->post2cat.post_ID “;
    $get_posts_in_cat .= “AND $wpdb->post2cat.category_id = ‘$catID’ “;
    $get_posts_in_cat .= “AND $wpdb->posts.post_status = ‘publish’ “;
    $get_posts_in_cat .= “ORDER BY $wpdb->posts.post_title “;

    $get_posts_in_cat_result = mysql_query($get_posts_in_cat);

    while ($posts_in_cat_row = mysql_fetch_assoc($get_posts_in_cat_result)) {
    $post_title = $posts_in_cat_row[‘post_title’];
    $postID = $posts_in_cat_row[‘ID’];
    $post_excerpt = $posts_in_cat_row[’post_excerpt’];

    echo ‘‘ . $post_title . ‘‘; echo ‘echo $post_excerpt’;
    }
    }

    ?>

    Thanks in advance for your help.

  29. Michael, you’ve probably already figured this out by now, but anyone else: the quote mark after DESC is backwards.

    Copy/paste this:

    $get_posts_in_cat .= “ORDER BY $wpdb->posts.post_date DESC “;

    Plugin is great!

  30. Can anyone help me order the posts by date? I need Newbie directions.

  31. Hi

    I am using the plugin at:
    Glass at Uzella Court Antiques.
    As you can see I am using it to display a list of products. What would be great is whether it is possible to attach a thumbnail of the image against each link. Would this be possible please?

    Thanks

    Rich

  32. Hi, thanks for the information. I Uploaded “wp_category_posts.php” to my “wp-content/plugins” directory. Now I’m in the process of putting the line:

    Forgive my ignorance, but I don’t know the proper syntax to replace the number (3) with the ID category I want to display, I called that category: most read.

    Can anybody give me some light in that matter, thanks in advance.

  33. littleoracle says:

    i heart this plug-in. it was exactly what i needed!

    thanks so much!

  34. I upgraded to WP 2.5 and it started giving me error…
    ================
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in wp/wp-content/plugins/wp_category_posts.php on line 25
    ===================

    Is there a way around it ?

    Thanks in advance !

  35. Richard says:

    I’ve been using your plugin for a quite a while and am very happy with it.

    Don’t know whether it’s a result of the recent WordPress upgrades – my blogs are on ver 2.51 – but an error is now displayed:

    ‘Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in …\wp_category_posts.php on line 25’

    The line in question reads:
    while ($posts_in_cat_row = mysql_fetch_assoc($get_posts_in_cat_result)) {

  36. Thanks for your plug-in!!
    Is possible that the list of post automatically update when I add a new post.
    Mybe the plug-in have a limit of post to show?
    Many thanks in advanced

  37. Could you update this plugin to work with WordPress 2.5.1? The database format has changed, and so this plugin no longer works with the new version.

  38. cheerful says:

    at wp 2.6

    ‘Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in …\wp_category_posts.php on line 25′

    :(???

  39. Hi,

    The plugin doesnt work with wordpress 2.6….will this be updated or is there another plugin like this that we can use ?

    Thanks
    Steve

  40. Hi, like others, I would like this plugin working in 2.6. Or is there any other solution?