[Plugin: comments-likes] pulling top 5 likes
-
Just a small function you can add to pull the 5 most liked comments
function cl_return_top_5() { global $wpdb; $cl_table_name = $wpdb->prefix . "comments_likes"; $liketop5 = $wpdb->get_results($wpdb->prepare("SELECT SUM(like_ID),like_comment_ID FROM $cl_table_name GROUP BY like_comment_ID ORDER BY SUM(like_ID) desc LIMIT 5;")); foreach ($liketop5 as $acomment) { $id_acomment = $acomment->like_comment_ID; $commentauthor = get_comment_author($id_acomment); $commentexcerpt = get_comment_excerpt($id_acomment); echo '<div class="commentliketop5">'; echo '<h3>'.$commentauthor.'</h3>'; echo '<p><a href="'.get_comment_link($id_acomment).'">'.$commentexcerpt.'</a></p>'; echo '</div>'; } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘[Plugin: comments-likes] pulling top 5 likes’ is closed to new replies.