Recommend on Google

A great way to reduce the amount of spam you receive is to disable the ability to comment on posts that are more than 1 month old. Just paste the following in your functions.php file.

<?php
		function close_comments( $posts ) {

			if ( !is_single() ) { return $posts; }

			if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 30 * 24 * 60 * 60 ) ) {
			$posts[0]->comment_status = 'closed';
			$posts[0]->ping_status    = 'closed';
			}

		return $posts;
		}
		add_filter( 'the_posts', 'close_comments' );
?>
Source: http://wpengineer.com/auto-shutoff-comments-and-trackbacks/
 

Leave a Comment