WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

By default "Discussion: Allow comments." is checked when a new page or post is created. I know you can make "Discussion: Allow comments." unchecked by default on both pages and posts by going to "Discussion Settings" and unchecking "Allow people to post comments on new articles".

I would like the default to be:

  • On posts: Discussion: Allow comments. (checked by default)
  • On pages: Discussion: Allow comments. (unchecked by default)

I do not want to use a plugin and don't want to modify the main WordPress code. I was hoping I could make a function in my functions.php file to do this?

Something like:

function disable_comments_on_pages() {

add_filter( '', 'disable_comments_on_pages' );
share|improve this question
This is something that should be done in a plugin and not in a theme (you will probably want the functionality to remain after theme switch), And unless you have many pages it will probably be faster and easier to turn comments off per page (your question implies they might be on for some pages) then to write code to have a separate default for pages. – Mark Kaplun Dec 29 '12 at 6:59

Hook into wp_insert_post, check if it is an auto-draft for a page, and set the comment_status to closed:

add_action( 'wp_insert_post', 't5_disable_default_comments_on_pages', 10, 2 );

function t5_disable_default_comments_on_pages( $post_ID, $post )
    remove_filter( current_filter(), __FUNCTION__ );

    if ( 'auto-draft' !== $post->post_status or 'page' !== $post->post_type )

    $post->comment_status = 'closed';

    wp_update_post( $post );
share|improve this answer

Your Answer


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.