对于某些类型的WordPress站点,也许不需要在页面(page)提供评论功能,那么你可以通过下面的方法,很容易就禁用或移除WordPress页面的评论功能。
方法1:在页面编辑界面取消该页面的评论功能

方法2:将下面的代码添加到当前主题的 functions.php 文件,即可禁用所有页面的评论功能:
//禁用页面的评论功能
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' ); |
//禁用页面的评论功能
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' );
方法3:直接打开当前主题的 page.php 文件,注销或删除类似下面的代码:
<?php if (comments_open()) comments_template( '', true ); ?> |
<?php if (comments_open()) comments_template( '', true ); ?>
来源:
https://www.wpdaxue.com/disable-or-remove-comments-of-wordpress-pages.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33211.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57