-1

i want to show how many comments has each post in the home page.

Searching the wordpress guide i found this code

<p>
  This post currently has
  <?php comments_number( 'no responses', 'one response', '% responses' ); ?>.
</p>

Where i have to put in? I use Twentyy Seventeen template.

Thank you.

2

First, you should look at creating a child theme. That way, any modifications you make won't be removed by a Wordpress update.

Next, edit wp-content/themes/twentyseventeen/template-parts/post/content.php and look for the following code:

        if ( is_single() ) {
                the_title( '<h1 class="entry-title">', '</h1>' );
        } elseif ( is_front_page() && is_home() ) {
                the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
        } else {
                the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
        }

After that, simply add the following:

// Show number of comments
echo '<div>(' . comments_number( 'no responses', 'one response', '% responses' ) . ')</div>';

This should show an output of
Your Page Title
(13 responses)

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.