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 am playing around with template hierarchy. I have uploaded stock 2012 theme and deleted page.php and single.php. I found that when I visit a blog post and click the the post reply link to leave a comment, the comment form doesn't show. So I copied comments_template() function out of single.php and pasted it into content.php inside the is_single conditional that looks like this

    <?php if ( is_single() ) : ?>
        <h1 class="entry-title"><?php the_title(); ?></h1>
        <?php else : ?>
        <h1 class="entry-title">
            <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
 //added the comments template here
 comments_template( '', true);
        <?php endif; // is_single() ?>

from that, I would expect the comments template to show but it does not. It did however show up when I added the is_single conditional to the index.php loop

Why would it not work in the

 get_template_part( 'content', get_post_format());
share|improve this question
the comments_template() code should be in the 'if' section. – Michael Feb 1 '13 at 8:44
up vote 0 down vote accepted

Looks like you're trying to display comments for a single post that has comments disabled.

You should find if ( comments_open() ) statement just one line below.

Paste your code there and it will work just fine:

            <?php if ( comments_open() ) : ?>
                <div class="comments-link">
                    <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
                </div><!-- .comments-link -->
                <?php comments_template( '', true); ?>
            <?php endif; // comments_open() ?>

Also, I can't find PHP starting & ending tag in your example, but I suppose it's just a typo? :)

Cheers, I hope it helps.

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.