get_query_var() not working in pre_get_posts

Did you try this?

function sort_query($query)
    if ($query->is_tax() && $query->is_main_query()){
        echo $query->query_vars['taxonomy']; 
        $query->set( 'orderby', 'post_title' );
        $query->set( 'order', 'ASC' );
        //do other stuff
    }
}
add_action('pre_get_posts', 'sort_query');

Happy Coding,

Kuchenundkakao

Leave a Comment

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