Support » Plugins » Hacks » If no comments

  • ald0413

    (@ald0413)


    HI,

    My client would like it if I could only show the number of comments if there are actually comments.

    I have tried the function reference from this page, https://codex.wordpress.org/Function_Reference/have_comments, but it doesn’t work, and it references twentyten, so I fear the information is out of date.

    Would someone be able to point me in the right direction?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator t-p

    (@t-p)

    what theme are you using?

    ald0413

    (@ald0413)

    I”m using a custom theme that I have created starting from BlankSlate

    Moderator t-p

    (@t-p)

    Try doing something like this in your theme’s comments.php:

    <?php if ( have_comments() ) : ?>
    		<h2 class="comments-title">
    			<?php
    				printf( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'twentythirteen' ),
    					number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
    			?>
    		</h2>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘If no comments’ is closed to new replies.