WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a custom post type single template. I noticed that when I turn off comments, I get a notice that says "Comments are closed."

Looking at my comments.php, I get this little bit of code:

     <?php else : // or, if we don't have comments:

        /* If there are no comments and comments are closed,
         * let's leave a little note, shall we?
         * But only on posts! We don't want the note on pages.
        if ( ! comments_open() && ! is_page() ) :
        <p class="nocomments"><?php _e( 'Comments are closed.', 'dukatheme' ); ?></p>
        <?php endif; // end ! comments_open() && ! is_page() ?>

This code makes it such that the notice is not shown on pages. How can I edit it to make sure it is not shown on pages AND my custom post type?

My custom post type is named "duka".


share|improve this question
up vote 3 down vote accepted

Add a post type check to the if clause;

if ( ! comments_open() && ! is_page() && 'duka' != get_post_type() ) :
share|improve this answer
Works like a charm! – Kelvin Jayanoris Mar 14 '11 at 19:38

I just do it directly on my templates... like in single.php

<?php if ( comments_open() ) : comments_template( '', true ); endif; ?>

Will that work for ya?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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