Forums

Comment Count for Specific Post (2 posts)

  1. kutu
    Member
    Posted 2 years ago #

    Below I'm calling the permalink for post 3770 and the title for post 3770 -

    How can a specify the comment count for post 3770? and specify the excerpt for post 3770?

    <h2>" title="<?php echo get_the_title(3770) ?> ">
    <?php echo get_the_title(3770) ?>
    <span class="commentcount"> (<?php comments_popup_link('0', '1', '%'); ?>)</span></h2>
    <?php the_excerpt(); ?>

    Thanks

  2. mugsinc
    Member
    Posted 2 years ago #

    <?php
    global $wpdb;
    $postID = 56;
    $title = get_the_title();
    $comments = $wpdb->get_row("SELECT comment_count as count FROM wp_posts WHERE ID = '$postID'");
    $commentcount = $comments->count;
    echo $commentcount;
    ?>

    try this worked for me, remember to change the post id to the one you want

Topic Closed

This topic has been closed to new replies.

About this Topic