/** * Wordpress一键关闭/开启评论功能 - 龙笑天下 * http://www.ilxtx.com/close-or-open-wordpress-comments.html * 超过限制天数或小时数后自动关闭WordPress文章的评论功能 */ function lxtx_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', 'lxtx_close_comments' );
/** * Wordpress一键关闭/开启评论功能 - 龙笑天下 * http://www.ilxtx.com/close-or-open-wordpress-comments.html * 当评论达到一定数量后自动关闭WordPress文章的评论功能 */ function lxtx_disable_comments( $posts ) { if ( !is_single() ) { return $posts; } if ( $posts[0]->comment_count > 100 ) { $posts[0]->comment_status = 'disabled'; $posts[0]->ping_status = 'disabled'; } return $posts; } add_filter( 'the_posts', 'lxtx_disable_comments' );
UPDATE wp_post SET comment_status='close'
UPDATE wp_post SET comment_status='open'
/** * Wordpress一键关闭/开启评论功能 - 龙笑天下 * http://www.ilxtx.com/close-or-open-wordpress-comments.html */ function close_open_comments( $posts ) { $postids = array('110','119'); if ( !emptyempty( $posts ) && is_singular() && !in_array($posts[0]->ID,$postids) ) { $posts[0]->comment_status = 'closed'; $posts[0]->post_status = 'closed'; } return $posts; } add_filter( 'the_posts', 'close_open_comments' );
站点统计
留言咨询