Advertise on Site! You can Advertise on our site. Find out More

Disable comments on posts after certain commment count in wordpress

Many people want to disable the post comments for some posts which has too many comments. Using simple code you can easily disable the comments for your posts which has many comments.

Here I written simple code. Using following code you can disable the comments which posts has more then 100 comments. you need to just put following code into your functions.php file.

<?php
$comment_count = 100;
function disable_comments( $posts ) {
 if ( !is_single() ) { return $posts; }
 if ( $posts[0]->comment_count > $comment_count ) {
 $posts[0]->comment_status = 'disabled';
 $posts[0]->ping_status = 'disabled';
 }
return $posts;
}
add_filter( 'the_posts', 'disable_comments' );
?>
Disable comments on posts after certain commment count in wordpress

Disable comments on posts after certain commment count in wordpress

  • http://forums.no-margin-for-errors.com/discussion/15177/i-am-the-new-guy Dan

    If you are going for best contents like myself, simply go to see this site all the time for the reason that it provides quality contents, thanks