WordPress Query with meta_key and order by another meta_key

Meta Query

meta_query takes an array of meta query arguments arrays. You may check WordPress documentation for examples.

This construct allows you to query multiple metadatas by using the relation parameter in the first (outer) array to describe the boolean relationship between the meta queries. Accepted arguments are ‘AND’, ‘OR’. The default is ‘AND’.

Solution

$loop = new WP_Query( [
    'post_type'      => 'studio',
    'posts_per_page' => -1,
    'post_status'    => 'publish',

    // meta_query argument is an array of one or many meta query arrays,
       even if you have just a single meta query
    'meta_query'     => array(
        array(
            'key'     => 'kk-zuschuss',
            'value'   => 'ja',
            'compare' => 'LIKE',
        ),
    ),

    'meta_key'       => 'name_teacher',
    'orderby'        => 'meta_value',
    'order'          => 'ASC',
] );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)