Disable All Comments and Trackbacks for Posts and Pages

Some wordpress site are only used as a content management system and don’t require comments and trackbacks.  For sites that already have content, these sql queries can be used to disable the comment and trackbacks with out having to manually edit each page/post.


UPDATE wp_posts SET comment_status='closed' WHERE post_status = 'publish' AND post_type = 'post';
UPDATE wp_posts SET comment_status='closed' WHERE post_status = 'publish' AND post_type = 'page';
UPDATE wp_posts SET comment_status='closed' WHERE post_type = 'attachment';
UPDATE wp_posts SET ping_status='closed' WHERE post_status = 'publish' AND post_type = 'post';
UPDATE wp_posts SET ping_status='closed' WHERE post_status = 'publish' AND post_type = 'page';
UPDATE wp_posts SET ping_status='closed' WHERE post_type = 'attachment';

Note: be sure to adjust the wordpress prefix to match the one defined in wp_config.php.

Scroll to Top