Advertisement
shansta

wordpress comment query

Dec 31st, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php get_header(); ?>
  2.  
  3. <ul class="double-cloumn clearfix">
  4. <li id="left-column">
  5. <ul class="blog-main-post-container">
  6. <?php
  7. $thisauthor = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
  8.  
  9. ?>
  10. <div style="float: right;">
  11. <? if(function_exists('get_avatar')) { echo get_avatar($thisauthor->user_email, 96, "" ); } ?> </div>
  12.  
  13. <h2><?php echo $thisauthor->first_name . " " . $thisauthor->last_name; ?> (<?php echo $thisauthor->display_name; ?>)</h2>
  14. <p><a href="<? echo $thisauthor->user_url; ?>"><? echo $thisauthor->user_url; ?></a><br />
  15. <a href="mailto:<? echo $thisauthor->user_email; ?>">email</a>
  16. <p><?php echo $thisauthor->description; ?> </p>
  17.  
  18. <?php if (have_posts()) : ?>
  19. <h2>Recent Posts </h2>
  20. <ul>
  21. <? while (have_posts()) : the_post(); ?>
  22. <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
  23.  
  24. <?php endwhile; else: ?>
  25. <li>This user hasn't published any posts. </li>
  26. <?php endif; ?>
  27. </ul>
  28.  
  29. <?php
  30. $some_email = $thisauthor->user_email;
  31. $querystr = "
  32. SELECT comment_ID, comment_post_ID, comment_content, post_title
  33. FROM $wpdb->comments, $wpdb->posts
  34. WHERE comment_author_email = '$some_email'
  35. AND comment_approved = 1
  36. GROUP BY comment_ID
  37. ORDER BY comment_ID DESC
  38. ";
  39. $comments_array = $wpdb->get_results($querystr, OBJECT);
  40.  
  41. if ($comments_array): ?>
  42. <h2>Recent Comments </h2>
  43. <ul>
  44. <? foreach ($comments_array as $comment):
  45. setup_postdata($comment);
  46. echo "<li><a href='". get_bloginfo('url') ."/?p=".$comment->comment_post_ID."'>Comment on ". $comment->post_title. "</a><br />". $comment->comment_content . "</li>";
  47. endforeach; ?>
  48. </ul>
  49. <? endif; ?>
  50. </ul>
  51.  
  52. </li>
  53. </ul>
  54. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement