• hi there I’m currently using the comment plugger at: https://dev.wp-plugins.org/browser/comment-plugger/

    but my problem is that I can’t get rid of the comma for the last commentor is there a way that I can do that?

    my site is at: https://log.serene-sky.net/

    Thanks

    Just in case if you need to see the plugger code then here it is:

    <?php
    /*
    Plugin Name: Comment Plugger
    Plugin URI: https://mtdewvirus.com/code/wordpress-plugins/
    Description: Gives a list of that last people to comment on a post, with a link to their site if they provided one.
    Version: 1.03
    Author: Nick Momrik
    Author URI: https://mtdewvirus.com/
    */

    function mdv_comment_plugger($before = ”, $limit = 5) {
    global $wpdb, $id;
    $request = “SELECT comment_author, comment_author_email, comment_author_url, MAX(comment_ID) as comment_ID FROM $wpdb->comments”;
    $request .= ” WHERE comment_post_ID=’$id’ AND comment_approved = ‘1’ GROUP BY comment_author_email ORDER BY comment_ID”;
    $request .= ($limit > 0) ? ” LIMIT $limit” : ”;
    $commenters = $wpdb->get_results($request);

    if ($commenters) {
    $output = ”;
    foreach ($commenters as $commenter) {
    if ($comment_author == “”)
    $comment_author = “anonymous”;
    if (!empty($commenter->comment_author_url))
    $output .= ‘comment_author_url . ‘” title=”‘ . $commenter->comment_author . ‘”>’ . $commenter->comment_author . ‘, ‘;
    else $output .= ‘ ‘ . $commenter->comment_author . ‘, ‘;
    }

    echo $before . ‘ ‘ . $output . ‘ ‘;
    }
    }
    ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • It will have to wait until I get home, but I think I can help you with that.

    Tg

    Try ,making the last lines look like this:

    if ($commenters) {
    $output = ”;
    foreach ($commenters as $commenter) {
    if ($comment_author == “”)
    $comment_author = “anonymous”;
    if (!empty($commenter->comment_author_url))
    $output .= ‘, ‘.’comment_author_url . ‘” title=”‘ . $commenter->comment_author . ‘”>’ . $commenter->comment_author . ‘, ‘;
    else
    $output .= ‘ ‘ . $commenter->comment_author;
    }

    echo $before . ‘ ‘ . $output . ‘ ‘;
    }
    }
    ?>

    What this does is not put the comma at the END of every author BUT actually put it in front of every NEW one added.

    So he old situation would be
    mike,
    mike, jack,
    mike, jack, audrey,

    The new situation would not put it at the end but in front of a new one:
    mike
    mike, jack
    mike, jack, audrey

    I hope I fromated the string / output array correctly ?? Just let me know :0p

    Thread Starter moggy

    (@moggy)

    hi mcmike I have just tried making the changes but I got a parse error @_@

    McMike’s suggestion is close but will actually end up creating:
    ,mike
    ,mike, jack
    etc.

    What you want to do is (with the original code) remove the two snippets that are adding the commas: . ', '

    Then add the following line just below the foreach statement:
    if (!empty($output)) $output .= ', ';

    Thread Starter moggy

    (@moggy)

    oh my goodness it worked darkcanuck! thank you so much ^__^

    No problem, happy to help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Comment Plugger Help’ is closed to new replies.