mercredi 4 mars 2015

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?





Aucun commentaire:

Enregistrer un commentaire