• Hi, I’m making a child theme for 2010 for this site http://www.quitcigs4free.com

    2010 has comments on the pages by default and I’d rather have them only on the posts. I would like to do this somehow with a hook and filter in functions.php in the child theme but I don’t know how.

    Is there a good place to go for this sort of information about child themes?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Open up your page.php and remove or comment this particular line of php code:

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

    I would advice you to comment out this code using // .This would make it easy if you need to restore comments on pages later.

    here’s a better solution i use…instead of removing the code,replace it with this:

    <?php $allow_comments = NULL; $allow_comments = get_post_meta($post->ID,’allow_comments’, false); ?>
    <?php if ($allow_comments[0]) { comments_template(); } ?>

    Now what you’re doing is creating a custom field for called allow_comments.So what you would need to do is set a custom field on pages called allow_comments and set its value to 1 or allow or anything.This code checks if your page has a value for comments and if it is present will display the comments field.You dont need to set any field if you dont want comments on the page.

    Thread Starter Rob Cubbon

    (@robcub)

    Hello abinav, thank you for these solutions. However, I’m using a child theme of 2010 so that when 2010 is updated I won’t lose all the changes I make. If I edit the page.php of 2010 and then 2010 is updated, won’t I lose the changes?

    That’s why I was wondering if there was a way of doing this within functions.php of the child theme.

    AardvarkGirl

    (@aardvarkgirl)

    I posted a ‘turn comments off on pages by default’ question yesterday… I’d love to find a way to do this with out ripping out the comments_templates – so that clients can opt to turn comments ON in a page (on a page by page basis).

    Thread Starter Rob Cubbon

    (@robcub)

    I might have this wrong AardvarkGirl, but I think you can do that. If you, on a Page go to Screen Options top right and check Discussion, you can then, at the bottom, uncheck Comment and Pings.

    I’ve just done this on 2010 and it works pretty well. But sometimes you get an ugly “Comments are currently turned off” message.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Taking comments off pages in 2010 child theme’ is closed to new replies.