Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Wordpress + Horizontal display of recent comments

Options
  • 17-08-2009 4:51pm
    #1
    Registered Users Posts: 28


    Hi all,

    Anyone any ideas on this.
    I have a jQuery marquee on the top of a wordpress site I am finishing off.
    I want to display the most recent comments in this marquee scrolling across the top of the screen.
    I can get text to scroll across and I can list the most recent comments outside the jquery marquee code but if i put the code to get the most recent comments inside the jquery marquee code, only 1 comment shows (the most recent one)
    I understand that the code is no longer looping through the comments but I cant figure out how to fix it.
    There are lots of methods and plugins to display the recent comments in a vertical list but I cant find anything for a horizontal list.

    Any help would be great thanks

    Here is the code involved:

    jQuery Marquee:
    http://jscroller.markusbordihn.de/example/left/

    Get Recent Comments:
    <?php
    $pre_HTML ="";
    $post_HTML ="";
    global $wpdb;
    $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10";

    $comments = $wpdb->get_results($sql);
    $output = $pre_HTML;
    $output .= "\n<ul>";
    foreach ($comments as $comment) {
    $output .= "\n<li>".strip_tags($comment->comment_author) .":" . "<a href=\"" . get_permalink($comment->ID)."#comment-" . $comment->comment_ID . "\" title=\"on ".$comment->post_title . "\">" . strip_tags($comment->com_excerpt)."</a></li>";
    }
    $output .= "\n</ul>";
    $output .= $post_HTML;
    echo $output;
    ?>


Advertisement