“Comments Are Closed” Problem in WordPress
Sometimes we are facing a major problem to have COMMENTS ARE CLOSED in WordPress site and there are several causes to happen this issue. If you find the solution in web many experts will deliver different types of method to get rid of. And most of them will ask you to run a SQL query.
And really this solution works :
//sql query UPDATE wp_posts SET comment_status = REPLACE (comment_status, 'closed', 'open') WHERE post_status = 'publish' AND post_type = 'post';
OR
//sql query UPDATE wp_posts SET comment_status = 'open', ping_status = 'open' WHERE comment_status = 'closed' AND post_status = 'publish';
But, it will be funny if you are really don’t know how to run SQL query OR if you don’t have permission to access your database. Then how ?? Yes, here i got a solution to post a function in your functions.php file which will solve your problem.
Just paste the below code in functions.php file.
//enable comments for all posts add_action('init', 'enable_comments_for_all_posts'); function enable_comments_for_all_posts(){ global $wpdb; $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open'", "")); // Enable comments $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET ping_status = 'open'", "")); // Enable trackbacks }
This post has already been read 6039 times!
I have tried many methods, but frankly this is the best method i tried and worked. Thanks for giving the exact solution.
This fixed the issue to me. Thanks a lot!
Hi, thanks for this helpful function!
I have a problem tho. With this function enabled, comments appear on *pages* as well as posts. Is there a way to disable comments from pages?
Thanks!
@Marcello, this function works for all comments whatever posts/pages. If you don’t want to display comments in *page* you might have option from theme settings otherwise you have to do from “page.php” file located at theme root folder. Just find the line “comments_template()” & remove/commented it. That’s all.