My query is not ordering my posts using the orderby
parameter.
A little background:
I'm within a foreach statement that loops through a custom taxonomy for "category" IDs. while in that foreach statement, I am attempting to invoke a new WP_Query getting posts from each "category" of that foreach loop. My args array is as follows:
$args = array(
'post_type' => 'wpsc-product',
'post_status' => 'publish',
'showposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'wpsc_product_category',
'field' => 'term_id',
'terms' => $cat_id,
),
array(
'taxonomy' => 'series',
'field' => 'slug',
'terms' => $series_name
)
),
'orderby' => 'title',
'order' => 'DESC'
);
$cat_id
and $series_name
are both arrays from my custom taxonomies in this post_type.
orderby
and order
are not working at all and I cannot figure this out why.
I have checked your code on my test blog. And it works as expected. So parameters
'orderby' => 'title',
'order' => 'DESC'
you have set correctly.
In this situation you can check SQL request.
$query = new WP_Query($args);
var_dump($query->request);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With