0

I would like to show comment count IN the post (not in post meta), is there a snippet how to do this or a wordpress internal shortcode?

  • 1
    Do you mean to display it in the post's content? Please show the current relevant code that you've tried so far, thanks. – birgire Apr 5 '17 at 8:27
1
add_filter('the_content','my_comment_count');

function my_comment_count($content) {

    $content .= get_comments_number(get_the_ID());

    return $content;
}
| improve this answer | |
  • Please, explain why this helps the OP instead of just posting the code. Thanks. – kaiser Apr 5 '17 at 13:24
0

Please add the following code into your theme's functions.php

    add_shortcode( 'comment_no', 'commno' );
    function commno(){

        $number= get_comments_number(get_the_ID());

        return $number;
}

and then you can use shortcode [comment_no] to display number of comments where you like.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.