Wordpress關(guān)閉所有評(píng)論有兩種方法:
1、后臺(tái)設(shè)置
進(jìn)入網(wǎng)頁Wordpress儀表盤,依此點(diǎn)擊設(shè)置 > 討論 > 取消勾選允許他人在新文章上發(fā)表評(píng)論
修改數(shù)據(jù)庫wordpress:將 wp_posts 表 comment_status、ping_status 值改為 closed
UPDATE `wp_posts` SET `comment_status` = 'closed' WHERE `wp_posts`.`ID` >1; UPDATE `wp_posts` SET `ping_status` = 'closed' WHERE `wp_posts`.`ID` >1;
2、修改主題中源程序代碼
在主題目錄下的functions.php文件中添加一段代碼
/**禁用博客評(píng)論功能*/
function disable_page_comments( $posts ) {
if ( is_page()) {
$posts[0]->comment_status = 'disabled';
$posts[0]->ping_status = 'disabled';
}
return $posts;
}
add_filter( 'the_posts', 'disable_page_comments' );以上就是Wordpress關(guān)閉所有評(píng)論的方法,希望對(duì)大家有所幫助。






