tax_query and sort by meta_key – no results
Question
I have query:
$tax_query = array(
'relation' => 'AND');
$tax_query[] = array(
'taxonomy' => 'kategoria',
'field' => 'id',
'terms' => $term->term_id,
);
if($_GET['kolor']) {
$tax_query[] = array('taxonomy' => 'kolor', 'field' => 'slug', 'terms' => $_GET['kolor']);
}
$query = new WP_Query( array( 'post_type' => 'produkt', 'posts_per_page' => 1000, 'tax_query' => $tax_query, ) );
And this works great, but I want to add sorting by custom field, so I edit query to the next one:
$query = new WP_Query( array( 'post_type' => 'produkt', 'posts_per_page' => 1000, 'tax_query' => $tax_query, 'meta_key' => 'kolejnosc', 'orderby' => 'meta_value_num', 'order' => 'ASC' ) );
And this isn’t working, result is just one item, when there’s a lot more.
0
sort, tax-query, wp-query
4 years
2020-02-11T08:39:03-05:00
2020-02-11T08:39:03-05:00 0 Answers
57 views
0
Leave an answer