Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Wordpress + Horizontal display of recent comments

  • 17-08-2009 04:51PM
    #1
    Registered Users, Registered Users 2 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