Filtering by multiple conditions in the loop

I’m trying to filter the posts in my index by multiple conditions.

So far I’ve tried with this:

<?php $query = new WP_Query(
    array(
          "post__not_in" =>get_option("sticky_posts"), 
          'paged' => get_query_var('paged'), 
          '&meta_key=Sortdate&orderby=meta_value&order=asc') 
         ); 
 ?>

With this piece of code, the first condition will be met, and it won’t list posts that are sticky, but the last one will be ignored, ordering the posts by publishing date and not by the meta field “Sortdate”.

On the other hand, if I do this:

<?php $query = new WP_Query(
          '&meta_key=Sortdate&orderby=meta_value&order=asc') 
 ?>

Then the order is correct, but I’m missing the other conditions.

What am I doing wrong?
Any tips?

Solutions Collecting From Web of "Filtering by multiple conditions in the loop"

You cannot mix array syntax and string syntax in the same argument. If you start with array syntax, you should stick with that, the same applies if you start with string syntax, then you should stick with string syntax. Because you are using post__not_in which is an array, you should stick with array syntax

<?php $query = new WP_Query(
    array(
          "post__not_in" =>get_option("sticky_posts"), 
          'paged' => get_query_var('paged'), 
          'meta_key' => 'Sortdate',
          'orderby' => 'meta_value',
          'order' => 'ASC'
       )  ); 
 ?>