Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

<?php
wp_reset_query();
if ( is_page_template(‘basic-template.php’) ) {
comments_template();
} 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!

share|improve this question
    
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
add comment

2 Answers 2

up vote 0 down vote accepted

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"

share|improve this answer
    
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
add comment

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

<?php
  if ( is_page_template("basic-template.php") ) {
    // do nothing (hide comments)
  } else {
    comments_template();
  }
?>
share|improve this answer
    
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
add comment

Your Answer

 
discard

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.