tax query term_id code example
Example 1: tax query by term id
<?php
$args = array(
'post_type' => 'recipe_cpt',
'tax_query' => array(
array(
'taxonomy' => 'recipe_tx',
'field' => 'term_id',
'terms' => 37
)
)
);
$query = new WP_Query( $args ); ?>
Example 2: wp query get ids
function carawebs_student_questionnaire_results(){
$args = array(
'post_type' => 'questionnaire-result',
'post_status' => 'publish',
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'user_type',
'value' => 'student',
'compare' => '=',
'type' => 'CHAR',
),
),
);
$result_query = new WP_Query( $args );
$ID_array = $result_query->posts;
wp_reset_postdata();
return $ID_array;
}