This does the same as above:
<?php if (!is_page('7')) comments_template(); ?>
The exclamation mark means NOT, so if not page 7 then display the comments template.
Also if you are only executing ONE statement inside an IF/ELSE block only then you don’t need to use the curly braces { } around it. If you are executing more than one then you need to use curly braces. For example:
<?php
//Here we don't need curly braces because we are only executing one statement
if($test) echo "Hello";
//Here we do need them because we are executing two statements
if($test){ echo "Hello"; echo "Hello Again"; }
?>
Thanks. I wonder though if I was thinking about it the wrong way…
I rewrote it so that comments would only display on the Sub Page IDs, versus _NOT_ displaying comments on the Parent Pages, thus only showing comments on Sub Pages.
Here’s what I got, an array of IDs.
<?php if (is_page(array(26,58))) comments_template(); ?>
This will only display the comments template if the Page has a parent:
<?php if($post->post_parent) comments_template(); ?>
But you could simply do this in the WP-admin, by turning off comments on the pages you don’t want the comments template on. If you don’t want the «Comments closed»-message, simply use:
<?php if(comments_open()) comments_template(); ?>