Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mal

macrumors 603
Original poster
Jan 6, 2002
6,253
30
Orlando
I am running a small Wordpress blog (still needs lots of content added, but the basics are there), but I want to keep comments enabled for posts, but not for pages. I was told I should remove the code to display the comment block from the page.php file, but I cannot for the life of me figure out what to remove. Here is the page.php file from the Mystique theme that I am using:

Code:
<?php /* ATOM/digitalnature */

   // The template for the "page" post type. It acts for pages just like single.php does for posts
   // pagename.php, page-slug.php or page-id.php can override it.

  get_header();
?>

  <!-- main content: primary + sidebar(s) -->
  <div id="mask-3" class="clear-block">
   <div id="mask-2">
    <div id="mask-1">
             
      <!-- primary content -->
      <div id="primary-content">
       <div class="blocks clear-block">
           
        <?php $app->action('before_primary'); ?>
          
        <?php if(have_posts()): ?>
          <div class="posts clear-block">
          <?php while(have_posts()): ?>
            <?php the_post(); ?>

            <?php $app->action('before_post'); ?>

            <!-- post -->
            <div id="post-<?php the_ID(); ?>" <?php post_class('primary'); ?>>

              <?php if(!$app->post->getMeta('hide_title')): ?>
              <h1 class="title"><?php the_title(); ?></h1>
              <?php endif; ?>

              <div class="clear-block">
                <?php the_content(); ?>
              </div>

              <?php $app->post->paginate(); ?>

              <?php $app->controls('post-edit'); ?>
            </div>
            <!-- /post -->
            <?php $app->action('after_post'); ?>

          <?php endwhile; ?>
          </div>

          <?php $app->template('meta'); ?>

        <?php else: ?>
          <h1 class="title error"><?php _ae('Oops, nothing here :('); ?></h1>
        <?php endif; ?>

        <?php $app->action('after_primary'); ?>

       </div>
      </div>
      <!-- /primary content -->

      <?php get_sidebar(); ?>
    </div>
   </div>
  </div>
  <!-- /main content -->

<?php get_footer(); ?>

My site is thebeardednerd.com, and I don't want comments to appear on the Contact Me or Services and Rates pages from the top nav.

Please help!

jW
 
PHP:
            <?php $app->action('after_post'); ?>

Is the one calling it. But this must be a really old version of the theme. This should now be handled with a call to comments_template();

You can remove the above or update and remove comments_template();
 
Yeah, the theme is actually not that great in terms of proper Wordpress code, as far as I can tell. I tried both commenting out and deleting that line from the template, but it didn't seem to work. I'll try again.

Anyone have a suggestion for a good up-to-date theme with a similar design that I could be using instead? I particularly like the header and menu part of this theme, although I do intend to have a custom logo eventually (I have a logo contest running on Facebook right now, though it's been a little dry).

jW
 
I am running a small Wordpress blog (still needs lots of content added, but the basics are there), but I want to keep comments enabled for posts, but not for pages.

Ok but why not make it easy on yourself? Uncheck the allow comments and allow pings from each page as you create them. You have the benefit of not having to hack up a theme every time it is updated or you try a different theme.

If you do need to hack up a theme, do make sure you are using child themes and not making changes to the original. Themes are often updated.
 
I'm using Mystique 3.1, so a newer version than the one you linked to, and not the lite version.

Not sure about paying for a theme at this point, but I'll look those over.

----------

Ok but why not make it easy on yourself? Uncheck the allow comments and allow pings from each page as you create them. You have the benefit of not having to hack up a theme every time it is updated or you try a different theme.

If you do need to hack up a theme, do make sure you are using child themes and not making changes to the original. Themes are often updated.

That would be my preference, but the comments checkbox does not appear when I'm creating or editing a page. Not sure why. I am using a child theme, btw.

jW
 
Might be a silly question, but before you go diving through the code, Wordpress usually lets you control comments per page through the dashboard. Open the pages through the dashboard and scroll down under the section where your type the content and you should see a section called Discussion. Just tick / untick the pages your do or don't want to see comments.

image1.jpg


If you don't see the discussion section check the section is visible through your screen option panel in the top right.

image2.jpg


While some themes may turn this off, just check here before you go scrubbing through the code.
 
Last edited by a moderator:
If you don't see the discussion section check the section is visible through your screen option panel in the top right.

Image

While some themes may turn this off, just check here before you go scrubbing through the code.

Thanks! That did the trick!

jW
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.