79085488

Date: 2024-10-14 09:13:58
Score: 2
Natty:
Report link

hey i have been looking for this answer

function enable_comments_by_default($post_id, $post, $update) {
    // Only affect new posts
    if ($update || 'my_custom_post' !== $post->post_type) {
        return;
    }

    // Enable comments and pingbacks
    if (!isset($post->comment_status)) {
        wp_update_post(array(
            'ID' => $post_id,
            'comment_status' => 'open',
            'ping_status' => 'open',
        ));
    }
}
add_action('wp_insert_post', 'enable_comments_by_default', 10, 3);
Reasons:
  • RegEx Blacklisted phrase (2): hey i have
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Vishwajit Kumar Kaushal