Disable comments on pages / articles In WordPress default

wp comments

How to disable comments on pages And articles in wordpress

Temporarily or permanently, there are many reasons for wanting to close the comments on an entire WordPress site. This tutorial will teach you how to disable one or more types of content, without using a plugin.

In a functions.php file of your theme, paste the following lines:
add_filter('comments_open', 'wpc_comments_closed', 10, 2);

function wpc_comments_closed( $open, $post_id ) {
$post = get_post( $post_id );
if ('post' == $post->post_type)
$open = false;
return $open;
}
On line 4, specify the type of content that you want to disable comments: Post for articles page for traditional pages or custom post types.

Back up and verify that all comments are now closed.

If you prefer to disable throughout your site, then remove the line with the condition indicated by the If.


Related :

How to better secure your wordpress blog ?

How to customize the Wordpress login page ?

Wordpress Seo Techniques For Beginner Bloggers
Disable comments on pages / articles In WordPress default Disable comments on pages / articles In WordPress default Reviewed by Nicole on March 20, 2015 Rating: 5
Powered by Blogger.