• Hello,

    I know that wordpress recently turned off comments on pages by default.

    Comments are now turned off on pages by default

    I used the following snippet and created a MU plugin. but it does not work and break my site.

    /**
     * Filter whether comments are open for a given post type.
     *
     * @param string $status       Default status for the given post type,
     *                             either 'open' or 'closed'.
     * @param string $post_type    Post type. Default is <code>post</code>.
     * @param string $comment_type Type of comment. Default is <code>comment</code>.
     * @return string (Maybe) filtered default status for the given post type.
     */
    function wpdocs_open_comments_for_myposttype( $status, $post_type, $comment_type ) {
        if ( 'myposttype' !== $post_type ) {
            return $status;
        }
    
        // You could be more specific here for different comment types if desired
        return 'open';
    }
    add_filter( 'get_default_comment_status', 'wpdocs_open_comments_for_myposttype', 10, 3 );

    how do I do it?

Viewing 1 replies (of 1 total)
  • You don’t a plugin for that. Just take the below steps & you will achieve it.

    There are two steps for that to enable. First, go to backend & open the pages that does not show comment form. Now go to ‘screen options’ at the top & check the checkbox that says ‘comments’. It will enable comments for that post.

    Secondly, you have to go code wise. If you check ‘twenty-fourteen’ theme. You will see a file ‘page.php’. In that file you will see the below code:
    if ( comments_open() || get_comments_number() ) {
    comments_template();
    }
    This will enable comment form in every single page. Check if you have such codes in your theme.

    Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘How do I enable comments on pages?’ is closed to new replies.