Showing post title in Most Commented list

Bring Your Business to LifeSupportPopular WidgetShowing post title in Most Commented list

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #45696
    coeurmechante
    Participant

    Hi,
    Lovely plugin, and I’ve managed to customise it a little for our needs. My client would like to be able to show the post titles in the Most Commented list, such as:

    $authorname IN $post_title
    (excerpt)

    I’m looking at the code and it seems I’m going to have to join the commented data with the post data via post ID, but am now sure how to do it, nor if there’s an easier way. Have you come across this? Any suggestions?

    #45699
    coeurmechante
    Participant

    Hi again,
    I figured it out myself.

    After line 88 on my code: foreach($comments as $comment){

    I added (sorry if it’s not pretty… I don’t see a way to add code):

    $post_titles = $wpdb->get_results(“SELECT * from $wpdb->posts WHERE ID=’$comment->comment_post_ID'”);
    foreach ($post_titles as $post_title){
    $the_post_title = ($post_title->post_title);
    $the_post_id = ($post_title->ID);

    }

    Then I can call $the_post_title and $the_permalink($the_post_id) where needed. There may be a more elegant solution, but this works for me!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.