Advertisement
shansta

Untitled

Jan 7th, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <?php
  2. $pid = $post->ID;
  3. $comment_query = "SELECT * FROM `wp_comments` WHERE comment_post_ID = ".$pid. " AND comment_approved = '1'";
  4. $comments_array = $wpdb->get_results($comment_query, OBJECT);
  5.  
  6. if ($comments_array):
  7. $cpp = 10; // Comments per page
  8. $wp_query->comments = count($comments_array);
  9. //echo $wp_query->found_posts;
  10. $wp_query->max_num_pages = ceil($wp_query->comments / $cpp);
  11. $on_page = intval(get_query_var('paged'));
  12. if($on_page == 0){ $on_page = 1; }
  13. $offset = ($on_page-1) * $cpp;
  14. $wp_query->request = "
  15. SELECT * FROM `wp_comments` WHERE comment_post_ID = ".$pid. " AND comment_approved = '1'
  16. LIMIT $cpp
  17. OFFSET $offset
  18. ";
  19. $newcomments = $wpdb->get_results($wp_query->request, OBJECT);
  20. ?>
  21. <div class="comments">
  22. <?php if ($newcomments) : ?>
  23. <a name="comments" id="comment_anchor"></a>
  24. <h3 class="section-title"><?php _(comments_number('No <span>Comments</span>','1 <span>Comment</span>','% <span>Comments</span>')); ?></h3>
  25. <ul class="comment-container">
  26. <?php
  27.  
  28. foreach ($newcomments as $comment) :
  29. if ($comment->comment_parent == 0) :
  30. $comment_table = $wpdb->prefix . "ocmx_comment_meta";
  31. $comment_meta_sql = "SELECT * FROM $comment_table WHERE commentId = ".$comment->comment_ID." LIMIT 1";
  32. $comment_meta = $wpdb->get_row($comment_meta_sql);
  33. $comment_type = get_comment_type();
  34.  
  35. $date = $comment->comment_date_gmt;
  36. $ctime = time_difference($date);
  37. $comment_user_id_get = $wpdb->prepare( "select ID from $wpdb->comments b INNER JOIN $wpdb->users a where a.user_login='$comment->comment_author'" );
  38. $comment_user_id = $wpdb->get_row( $comment_user_id_get );
  39. $loverid = $comment_user_id->ID;
  40. $social_img = get_cimyFieldValue($loverid, 'PROFILE_SOC_IMG');
  41. $social_img_result = cimy_uef_sanitize_content($social_img);
  42. $twitty_value = get_user_meta($loverid,'twitty',true);
  43. $fb_value = get_user_meta($loverid, 'facebook', true);
  44. ?>
  45. .........
  46.  
  47. <?php endif; ?>
  48. <?php endforeach; ?>
  49. <? endif; ?>
  50. <li id="new_comments"></li>
  51. </ul>
  52. <?php else : ?>
  53. <a name="comments" id="comment_anchor"></a>
  54. <div id="new_comments"></div>
  55.  
  56. <?php endif; ?>
  57. </div>
  58. <div class="pag_pos">
  59. <?php wp_pagenavi(); ?>
  60. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement