wp_query on wp_theatre_prod with custom field for sorting
-
When I do a query and add the order/orderby options I don’t get the expected results (the result is not ordered). This is my query
$args = array( 'post_type' => 'wp_theatre_prod', 'post_status' => 'publish', 'posts_per_page' => -1, 'category_name' => $eencategorie, 'orderby' => 'meta_value_num', // orderby the meta_value of the following meta_key 'meta_key' => 'volgorde', // the custom meta_key name 'order'=> 'ASC' // sort descending ); $wp_query = new WP_Query( $args );
I’ve created a (numeric) custom field ‘volgorde’ to irder the productions.
But the result is never ordered? The query itself show this:
SELECT sw_posts.* FROM sw_posts LEFT JOIN sw_term_relationships ON (sw_posts.ID = sw_term_relationships.object_id) INNER JOIN sw_postmeta ON ( sw_posts.ID = sw_postmeta.post_id ) WHERE 1=1 AND ( sw_term_relationships.term_taxonomy_id IN (4) ) AND ( sw_postmeta.meta_key = '_wpt_order' ) AND sw_posts.post_type = 'wp_theatre_prod' AND ((sw_posts.post_status = 'publish')) GROUP BY sw_posts.ID ORDER BY sw_postmeta.meta_value+0 ASC
Is it the sw_postmeta.meta_key = ‘_wpt_order’ which is overruling my query?
- The topic ‘wp_query on wp_theatre_prod with custom field for sorting’ is closed to new replies.