I made a query where it should be ordered by the field external link then by price field the problem it seems that some of the post have multiple category can't seem to figure out why it is not going by order of external link fiend then by price field.
$query = new WP_Query( array(
'post_type' => post,
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
'price_clause' => array(
'key' => 'price',
'compare' => 'EXISTS'
),
'external_clause' => array(
'key' => 'external_link',
'compare' => 'EXISTS'
)
),
'orderby' => array(
'external_clause' => 'DESC',
'price_clause' => 'DESC',
),
'tax_query' => array(array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $category,
),)
) );
I made a query where it should be ordered by the field external link then by price field the problem it seems that some of the post have multiple category can't seem to figure out why it is not going by order of external link fiend then by price field.
$query = new WP_Query( array(
'post_type' => post,
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
'price_clause' => array(
'key' => 'price',
'compare' => 'EXISTS'
),
'external_clause' => array(
'key' => 'external_link',
'compare' => 'EXISTS'
)
),
'orderby' => array(
'external_clause' => 'DESC',
'price_clause' => 'DESC',
),
'tax_query' => array(array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $category,
),)
) );
I manage to fixed this the problem was type => 'numeric'
$query = new WP_Query( array(
'post_type' => post,
'posts_per_page' => -1,
'category_name' => $category,
'meta_query' => array(
'relation' => 'AND',
'price_clause' => array(
'key' => 'price',
'type' => 'numeric',
'compare' => 'EXISTS'
),
'external_clause' => array(
'key' => 'external_link',
'compare' => 'EXISTS'
)
),
'orderby' => array(
'external_clause' => 'DESC',
'price_clause' => 'DESC',
),
) );