wordpress后台只显示指定分类

 wordpress后台只显示指定分类

 



function mogublog_load_post_new(){
    add_filter('query', 'mogublog_custom_cats');
}

add_filter('load-post-new.php', 'mogublog_load_post_new');

function mogublog_custom_cats($query){
    if(strpos($query, "WHERE tt.taxonomy IN ('category')") !== false){
        global $current_user;
        get_currentuserinfo();
        $user_id = $current_user->ID;
        if($user_id == '1'){
            $query = str_replace("WHERE tt.taxonomy IN ('category')", "WHERE tt.taxonomy IN ('category') AND t.term_id IN (1, 2) ", $query);
        }
    }
    return $query;
}


发表评论