在WordPress中,如果你想关闭作者中心的功能,可以通过禁用用户的编辑器角色来实现。
以下是通过 主题 functions.php
文件来禁用作者中心的代码示例:
// 禁用作者中心
add_action( ‘init’, ‘disable_author_center’ );
function disable_author_center() {
remove_menu_page( ‘edit.php?author=’ . get_current_user_id() );
}
// 禁用作者编辑链接
add_filter( ‘get_the_author_link’, ‘disable_author_link’, 10, 4 );
function disable_author_link( $link ) {
return get_the_author_meta( ‘display_name’, get_query_var( ‘author’ ) );
}
// 禁用作者元链接
add_filter( ‘author_link’, ‘disable_author_box_link’, 20, 3 );
function disable_author_box_link( $link, $author_id, $author_name ) {
return get_the_author_meta( ‘display_name’, $author_id );
}
将上述代码添加到你的WordPress主题的 functions.php
文件中,可以完全禁用作者中心的显示。
这将同时移除后台的作者中心菜单项,并且在文章页面和其他地方隐藏作者的编辑链接和作者元框链接。