WordPress交流讨论群组

wordpress中只显示作者自己的文章

0 replies, 1 voice 最后回应 果舍网的头像 果舍网 3 years ago
  • Author
    Posts
  • #21860
    果舍网的头像
    果舍网
    Keymaster
    @guoshe
    function guoshe_query_useronly( $wp_query ) {
        if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
            if ( !current_user_can( 'level_10' ) ) {
                global $current_user;
                $wp_query->set( 'author', $current_user->id );
            }
        }
    }
     
    add_filter('parse_query', 'guoshe_query_useronly' );

You must be logged in to reply to this topic.