久久久精品2019免费观看_亚洲国产精品成人久久久_69国产成人综合久久精品91_国产精品久久精品视

wordpress:評論達到一定數(shù)量時自動關閉評論的設

  核心提示:打開當前主題的functions.php文件,添加//評論超過一定數(shù)量關閉評論 function disable_comments( $posts ) { if ( !is_single() ) { return $posts; } if ( $posts[0]-comment_count50 ) …

  打開當前主題的functions.php文件,添加

//評論超過一定數(shù)量關閉評論 function disable_comments( $posts ) { if ( !is_single() ) { return $posts; } if ( $posts[0]->comment_count > 50 ) { $posts[0]->comment_status = 'disabled'; $posts[0]->ping_status = 'disabled'; } return $posts; } add_filter( 'the_posts', 'disable_comments' );
123456789101112 //評論超過一定數(shù)量關閉評論function disable_comments( $posts ) {if ( !is_single() ) {return $posts;}if ( $posts[0]->comment_count > 50 ) {$posts[0]->comment_status = 'disabled';$posts[0]->ping_status = 'disabled';}return $posts;}add_filter( 'the_posts', 'disable_comments' );

其中,50可以修改成自己需要的數(shù)字,表示一篇文章的評論如果超過這個數(shù)值,則自動關閉評論。

未經(jīng)允許不得轉(zhuǎn)載:445IT之家 » wordpress:評論達到一定數(shù)量時自動關閉評論的設

贊 (0) 打賞

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

微信掃一掃打賞