I have a custom post called person and a taxonomy(like tags) called age. As far I have search tax query doesn't seem to support the between operator like meta query does.
Is there a way to accomplish the between, like etc operators with tax query or do I have to make my own sql question ?
Also would be better to create a custom field called age rather have a taxonomy and query with meta query that supports the compare operators ? One disadvantage I can think with using custom fields is that you can't query inside the admin panel how many people have that age or query only the people that have a certain age etc. Also if I want to find the min and max age of all people I have to get all posts and compare them one by one.
One solution I found to emulate the between operator :
$min_age = 18;
$max_age = 100;
$ages = array();
for($i=$min_age; $i<=max_age; $i++){
array_push($ages , $i);
}
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'age',
'field' => 'slug',
'terms' => $ages
)
)
);
$query = new WP_Query( $args );
So what do you think is better to do ?
I know my question is a bit vague and sorry for that but I would like to know what is the best solution to this kind of situations.