Hello @hmishkoff, to enable comments by default, go to your WordPress dashboard, navigate to Settings > Discussion, and ensure the checkbox next to “Allow people to submit comments on new posts” is checked.
This resource can be helpful: https://wordpress.com/support/comments/
That doesn’t help. 😥 That appears to apply to posts, perhaps there’s a different procedure for pages?
lisa
(@contentiskey)
try something like this – put the following code in a custom plugin or install a plugin like code snippets and put the code in a snippet
test in a local environment before adding to a live site
<?php
// Enable comments for new pages by default
add_action('wp_insert_post', function($post_id, $post, $update) {
if ($post->post_type === 'page' && !$update) {
update_post_meta($post_id, '_allow_comments', 1);
wp_update_post(['ID' => $post_id, 'comment_status' => 'open']);
}
}, 10, 3);
// Enable comments for existing pages (one-time script)
add_action('init', function() {
$pages = get_posts(['post_type' => 'page', 'post_status' => 'publish', 'numberposts' => -1]);
foreach ($pages as $page) {
if (get_post_meta($page->ID, '_allow_comments', true) !== '1') {
wp_update_post(['ID' => $page->ID, 'comment_status' => 'open']);
update_post_meta($page->ID, '_allow_comments', 1);
}
}
});
?>
(code was generated with assistance of AI tool)
-
This reply was modified 1 year, 5 months ago by
lisa.
I was hoping that there might be a non-coding solution, but I’ll give that a shot, thanks.
(@hmishkoff)
1 year, 5 months ago
When I create a new page, the default for Discussion is Closed. Is there a setting I can change so that Discussion defaults to Open on a new page? I’ve tried playing with the Discussion Settings, but I can’t figure anything out. Thanks!
The page I need help with: [log in to see the link]