Salman
Salman

Reputation: 112

asc and desc is not working in custom tax_query in WP_Query

$args = array(
            'post_type' => 'quizz_orelo',
            'posts_per_page' => -1,
            'orderby' => 'ID',
            'order' => 'ASC',
            'post_status' => 'publish',
            'tax_query'=> array(
            array(
              'taxonomy' => 'quizz_item_category',
              'field' => 'id',
              'terms' => $cat
            )
           )
          );

ASC and DSC is not wokring in WordPress, I've tried everything to summerize it but nothing is working, can you please

SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (543) ) AND wp_posts.post_type = 'quizz_orelo' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order , wp_posts.post_date DESC 

Upvotes: 1

Views: 242

Answers (1)

Salman
Salman

Reputation: 112

Thank you so much, I solved it, I was forgetting to reset all order first, i do it by putting

remove_all_filters('posts_orderby');

Upvotes: 1

Related Questions