Show/Hide comment status text in wordpress

I am again confused if my post title is perfect or not 🙁 So let me explain, sometimes we disable comment for any post or page and at last the text shows “Comments are closed” or something else in different ways. But in commercial projects we need to follow some good design where in some posts or pages we may need to enable comment or not. So, let’s put a trick in theme to show the comment text(comment status in more smart way)

In latest wordpress version the loop is in the loop.php file in the theme folder. So for comment we will get this line

<?php comments_template( '', true ); ?

But how about we put

<?php if($post->comment_status == "open"){comments_template( '', true );} ?>

That means if comment is off then we will not show any text like “Comments are closed” . I strongly believe this trick will make the design clean in some condition 😛

Thank you

2 Responses to “Show/Hide comment status text in wordpress”

Leave a Reply

Your email address will not be published. Required fields are marked *