WordPress 禁止作者为文章设置标签

如果你正在管理一个大型WordPress网站,允许用户角色为作者或贡献者的用户在后台投递文章,但是他们可能对于文章标签的设置不够专业,所以不希望由他们自己设置文章标签

解决此问题的最简单方法之一是让管理员和编辑这两个角色以下的用户角色无法设置文章标签。所用到的代码如下:

/**
 * WordPress 禁止作者为文章设置标签
 * https://www.wpdaxue.com/disallow-authors-from-assigning-post-tags.html
 */
function wpdaxue_disallow_tags_for_author( $taxonomy ) {
    global $wp_taxonomies;
    if ('post_tag' === $taxonomy) {
        $wp_taxonomies[$taxonomy]->cap->assign_terms = 'edit_others_posts';
    }
}
add_action('registered_taxonomy', 'wpdaxue_disallow_tags_for_author');

将上面的代码添加到主题的 functions.php 文件,或者你的其他功能插件中。

来源:

https://www.wpdaxue.com/disallow-authors-from-assigning-post-tags.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_33038.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?