WordPress.org

Ready to get started?Download WordPress

Forums

wp_category_posts - show number of comments? (2 posts)

  1. pschwar
    Member
    Posted 8 years ago #

    I love Brian Groce's "WP Category Posts" plug-in - but I'd love it even more if I was able to display the number of comments for each post along with the title. Does any know how to do this??

    The db query looks like this (i've edited it a bit to pull the body of the post as well...

    $get_posts_in_cat = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_content, $wpdb->posts.post_date,";
    $get_posts_in_cat .= "$wpdb->post2cat.post_id, $wpdb->post2cat.category_id ";
    $get_posts_in_cat .= "FROM $wpdb->posts, $wpdb->post2cat ";
    $get_posts_in_cat .= "WHERE $wpdb->posts.ID = $wpdb->post2cat.post_ID ";
    $get_posts_in_cat .= "AND $wpdb->post2cat.category_id = '$catID' ";
    $get_posts_in_cat .= "AND $wpdb->posts.post_status = 'publish' ";
    $get_posts_in_cat .= "ORDER BY $wpdb->posts.post_date DESC";

    Thanks!! :-)

  2. pschwar
    Member
    Posted 8 years ago #

    Any help? :-)

Topic Closed

This topic has been closed to new replies.

About this Topic