Forums

[resolved] How to display recent comments in a single category? (4 posts)

  1. dss
    Member
    Posted 2 years ago #

    I've been searching high and low, reading the codex, and investigating every recent comments plugin I can find, but have had no luck at all.

    I want to show four different lists on my index.php of the 5 most recent comments in each of my four categories -- one list for each.

    I've found so many way to display a single list in my sidebar, but nothing which will allow me to call individual lists for each category.

    Confused about why this seems so elusive.

  2. songdogtech
    Member
    Posted 2 years ago #

    Doesn't seem like there's a template tag for recent comments, but here's a code snip in a thread that someone says works. And another thread about using the output from a plugin in a different way.

  3. dss
    Member
    Posted 2 years ago #

    I think it's very strange that there's no way to do this...

  4. dss
    Member
    Posted 2 years ago #

    I solved this issue. It's an inelegant solution, but it's working as expected.

    Here's what I did:
    1. get a copy of the Get Recent Comments plugin.
    2. make a copy of it
    3. open the get-recent-comments.php and carefully edit each use of the following expressions:

    get-recent-comments
    get_recent_comments
    get_recent_trackbacks
    Recent Comments
    kjgrc_

    change these to read:

    get-recent-comments2
    get_recent_comments2
    get_recent_trackbacks2
    Recent Comments 2
    kjgrc2_

    Now be sure you change the name of the folder to "Get Recent Comments 2" or whatever you want, and the name of the "get-recent-comments.php" or whatever you want.

    Load this into your plugins folder and activate it.
    If you get an error, note what the error is, and this will usually tell you where you missed a duplicate name, function, or other registered piece of the plugin (go in and correct it) or that you have bungled it completely and should start over.

    Now call this plugin with this call:


    <?php if (function_exists('get_recent_comments2')) : ?>

      <?php get_recent_comments2(); ?>

    <?php endif; ?>

    Now go into the admin settings, and exclude the categories you want off this second list and update your settings.

    I've repeated this for the four categories I display on my index, so I've got four lovely little lists of single categories, and the corresponding comments below.

    It's cumbersome, but it's working!

Topic Closed

This topic has been closed to new replies.

About this Topic