WordPress 4.3+ 默认开启页面的评论功能

WordPress 4.3 及后续版本将页面(page)的评论功能默认关闭了,也就是说,你如果新建页面,需要手动勾选”允许评论”才可以开启页面的评论功能,这个对于经常要发布可评论页面的用户来说,无疑增加了操作量。

2015-08-26_093134_wpdaxue_com

如果你想要默认开启页面的评论功能,那你可以下载安装 Allow Comments on Pages by Default 插件,或者将下面的代码添加到主题的 functions.php 即可:

/*
Plugin Name: Allow Comments on Pages by Default
Plugin URI: https://wordpress.org/plugins/allow-comments-on-pages-by-default/
Description: Turns on comments on pages in <a href="https://www.wpdaxue.com/tag/wordpress-4-3" title="查看与【WordPress 4.3】相关的文章" target="_blank" rel="noopener">WordPress 4.3</a>+ by default.
Author: Sergey Biryukov
Author URI: http://sergeybiryukov.ru/
Version: 1.0
*/
function wp33516_open_comments_for_pages( $status, $post_type, $comment_type ) {
    if ( 'page' === $post_type ) {
        $status = 'open';
    }
    return $status;
}
add_filter( 'get_default_comment_status', 'wp33516_open_comments_for_pages', 10, 3 );

来源:

https://www.wpdaxue.com/wordpress-open-comments-for-pages.html

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?