Posted By

laurentzziu on 11/15/10


Tagged

wordpress comments recent


Versions (?)

Wordpress Recent Comments


 / Published in: PHP
 

  1. <?php
  2. global $wpdb;
  3. $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
  4. comment_post_ID, comment_author, comment_date_gmt, comment_approved,
  5. comment_type,comment_author_url,
  6. SUBSTRING(comment_content,1,30) AS com_excerpt
  7. FROM $wpdb->comments
  8. LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
  9. $wpdb->posts.ID)
  10. WHERE comment_approved = '1' AND comment_type = '' AND
  11. post_password = ''
  12. ORDER BY comment_date_gmt DESC
  13. LIMIT 10";
  14. $comments = $wpdb->get_results($sql);
  15. $output = $pre_HTML;
  16. $output .= "\n<ul>";
  17. foreach ($comments as $comment) {
  18. $output .= "\n<li>".strip_tags($comment->comment_author)
  19. .":" . "<a href=\"" . get_permalink($comment->ID) .
  20. "#comment-" . $comment->comment_ID . "\" title=\"on " .
  21. $comment->post_title . "\">" . strip_tags($comment->com_excerpt)
  22. ."</a></li>";
  23. }
  24. $output .= "\n</ul>";
  25. $output .= $post_HTML;
  26. echo $output;?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: killjim01 on October 18, 2014

red bottom heels oakley sunglasses wholesale chi flat iron,chi hair strighteners toms wedges michael kors sale marc jacobs,marc jacobs handbags,marc jacobs bags,marc jacobs outlet moncler jackets christian louboutin,christian louboutin shoes,christian louboutin outlet fitflop coach outlet stores ugg shoes,uggs for cheap,uggs outlet,uggs for kids,ugg boots sale,uggs sale,uggs on sale,ugg gloves,ugg bailey button,ugg boots cheap,ugg moccasins,uggs canada,uggs for women,fake uggs,ugg boots,ugg uk,ugg boots on sale coach factory outlet coach cyber monday 2014,coach cyber monday,cyber monday 2014,cyber monday deals,cyber monday sales,cyber monday,louis vuitton cyber monday 2014,louis vuitton cyber monday,michael kors cyber monday 2014,michael kors cyber monday

You need to login to post a comment.