For example, I have the following code on the main page (index.php):
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div id="entry"> <h3><?php the_title(); ?></h3> <?php the_content(); ?> — <?php the_time('d F, Y') ?> | <a href="#"><?php comments_number() ?></a> </div> <?php endwhile; ?> <?php endif; ?>
And let’s assume I don’t have any comments right now. Then how do I hide the empty link and the “|” symbol? I don’t want to display “0 comments” or anything like it. Just want it to dissapear if no comments added, and then appear if at least one comment was added.
I have plugin installed that manages parameters of comments_number, so it’s not an option to modify it.
I tried to use
<?php if ( have_comments() ) : ?>and other similar code infront of the comments_number, but without any result.
- The topic ‘If comments number in Post Loop’ is closed to new replies.