I'm new to Wordpress and I'm trying to edit the Twenty Ten theme so that my template for basic pages (basic-template.php) does not show the comments box. I do want the comments box to show up on other pages, such as blog posts. I'm pretty sure that changes need to be made in loop.php, but my doesn't seem to be having the right effect. For the comments box, I edited:

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

to be as follows.

if ( is_page_template(‘basic-template.php’) ) {
} else {
comments_template( '', true );

When I get rid of the else statement, the comments disappear, so I think the problem is my code for that part. Any advice would be much appreciated!

  • the change might need to be done in loop-page.php; depending on the line in your basic-template.php – Michael May 25 '11 at 7:33
  • @Michael, thanks for your post. Unfortunately, that didn't do the trick. I have used the code above in place of <?php comments_template( '', true ); ?> for these TwentyTen files: loop.php, loop-page.php, loop-single.php. It has no effect. My basic template references get_template_part( 'loop', 'index' ); Is my replacement code right? – KDP May 25 '11 at 20:28
  • @KPD - i just realized that there are the odd quotes around the template name: ( is_page_template(‘basic-template.php’) ) - check this in your code, and try and replace them with the straight single quotes ' – Michael May 26 '11 at 9:45
  • @Michael, again, thanks for the note. I did change them to single quotes, but I still have the same problem. When I just have this part of the code, comments disappear, which is what I want: <?php wp_reset_query(); if ( is_page_template(‘basic-template.php’) ) { comments_template(); } ?> However, when I put in the "Else" statement, comments appear again, even though I'm using the basic-template.php. I think there's something wrong with my "Else" statement. Any thoughts? – KDP May 26 '11 at 16:16

You can turn off the discussion per post/page when you're creating new posts/pages. this option is usually below the text editor and is often hidden. In order to bring it up, you might have to click on "Screen Options" at the top of the page and check the box next to "Discussion"

  • I appreciate your response, but I am looking for a solution that removes the comment box as well as the "Comments Closed" message from a specific page template every time. PHP is the only way I can see to do this. If you've got a fix for that, please do let me know. Thanks! – KDP May 25 '11 at 20:31

I could have interpreted badly your intentions but shouldn't your code be:

  if ( is_page_template("basic-template.php") ) {
    // do nothing (hide comments)
  } else {
  • Great! I think that does the trick. Thanks, Drake. – KDP Jun 4 '11 at 21:58
  • @KDP You are welcome, if it answered your question, please vote up and mark mine as anwser. – Drake Jun 5 '11 at 11:03
  • Drake, sorry this is so late in coming, but I'm unable to vote up because of my "reputation" (I've got less than 15.) Thanks again for your help, though! – KDP Mar 28 '12 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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