I have post type called “brand” and taxonomy called “category_brand”. Under the “brand” post type I have a repeater field. That repeater field Includes two sub fields: number field called “grade”, and taxonomy field called “category” (the taxonomy display all the categories under “category_brand”)
it looks like this: the repeater field
In the taxonomy archive of “category_brand” I display only the “brands” of the current taxonomy.
The order of the posts need to be by the “grade” sub fields, (large to small number).
I’m troubling with getting the ‘meta_key’ from the grade field under the repeater. The thing is that I need to get the “grade” field only if it’s related to the current taxonomy – The “category” sub field in the repeater.
This is the code
$current_object=get_queried_object();
$current_object_tax= $current_object->taxonomy;
$current_object_tax_id= $current_object->term_id;
$post_args_current_tax = array(
‘post_type’ => ‘brands’,
‘tax_query’ => array(
array(
‘taxonomy’=> $current_object_tax,
‘field’=> ‘term_id’,
‘terms’ => $current_object_tax_id,
),
),
‘posts_per_page’ => -1,
‘meta_key’=> ‘categorygrade_0_grade’,
‘orderby’=> ‘meta_value_num’,
‘order’ => ‘DESC’,
);
$post_query_current_tax = new WP_Query($post_args_current_tax);
Right now this meta_key:’meta_key’=> ‘categorygrade_0_grade’, takes all the grades under the repeater and not only the grades that related to the current taxonomy. How can I get the grade only if it’s related to the current taxonomy in the repeater?