I want to avoid comments in pages but allow them only

Hi,

I want to avoid comments in pages but allow them only in posts. If I go in Settings -> Discussions and set to avoid comments, it will avoid also in posts.

I do not want to uncheck the box manually in Screen Options -> Discussion for each page.

How to automatically avoid comments only for pages?

Thanks.

  • Vaughan
    • Support/SLS MockingJay

    Hi @Andreza,

    Once you set the option in screen options it should stay like that for any future posts.

    The problem is if you already have hundreds of existing pages.

    In that case, you could use phpmyadmin and use SQL to turn it off for existing pages.

    UPDATE wp_posts SET comment_status = 'closed' WHERE post_type = 'page';

    Alternatively, you can edit the theme templates, such as page.php or single.php and remove the comment PHP code

    <?php comments_template(); ?>

    Removing the above line from the page templates will permanently disable comments for pages.

    Hope this helps

  • Andreza
    • The Incredible Code Injector

    Once you set the option in screen options it should stay like that for any future posts.

    If I create a page and uncheck the Discussion box, then the next pages I create have this option checked.

    If I disable the commets in Settings -> Discussions and then I check the Discussion box to allow comments in a post, when I create another posts this option is not checked as you said.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.