WordPress 4.3+ 默認開啟頁面的迴響功能

WordPress 4.3 及後續版本將頁面(page)的迴響功能默認關閉瞭,也就是說,你如果新建頁面,需要手動勾選”允許迴響”才可以開啟頁面的迴響功能,這個對於經常要發佈可迴響頁面的用戶來說,無疑增加瞭操作量。

2015-08-26_093134_wpdaxue_com

如果你想要默認開啟頁面的迴響功能,那你可以下載安裝 Allow Comments on Pages by Default 外掛,或者將下面的代碼添加到主題的 functions.php 即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
Plugin Name: Allow Comments on Pages by Default
Plugin URI: http://wordpress.org/plugins/allow-comments-on-pages-by-default/
Description: Turns on comments on pages in WordPress 4.3+ 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 );

/*
Plugin Name: Allow Comments on Pages by Default
Plugin URI: http://wordpress.org/plugins/allow-comments-on-pages-by-default/
Description: Turns on comments on pages in WordPress 4.3+ 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 );

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *