对于WordPress多作者博客,如何让每个作者在后台只能浏览自己的文章?只需要将下面的代码添加到你主题的 functions.php 即可:
function mypo_parse_query_useronly( $wp_query ) {
if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
if ( !current_user_can( 'manage_options' ) ) {
global $current_user;
$wp_query->set( 'author', $current_user->id );
}
}
}
add_filter('parse_query', 'mypo_parse_query_useronly' );
以上代码排除了对管理员的限制,也就是管理员是可以看到所有人的文章的。
本文转自:https://www.wpdaxue.com/only-display-the-author-posts-in-the-admin-post-list.html
叨叨几句... NOTHING