I’m attempting to make use of a tax question in my pre_get_posts
perform. All is working however not when the array has a number of IDs. As an instance my URL appears to be like like: ?listing_cat[]=1&listing_cat[]=2
Now I’m attempting to filter out posts which might be in these 2 classes. However my filter solely will get the posts from the primary class ID. I assume I’ll want a foreach perform, however I’m not positive tips on how to implement this. At the moment I’ve the code under. Now I do know I can use filter by a number of phrases with a comma, like : 'phrases' => array($rt_cat_id[0], $rt_cat_id[1])
, however I simply want it to mechanically get all of the phrases from the array $rt_cat_id
and use these to filter the posts. Find out how to accomplish that? Thanks
add_action( 'pre_get_posts', 'rt_tax_archive' );
perform rt_tax_archive($question) {
$rt_cat_id = $_GET['listing_cat'];
if( isset( $rt_cat_id ) && ! empty( $rt_cat_id[0] ) ) {
$tax_query[] = array(
'taxonomy' => 'listing_category',
'subject' => 'id',
'phrases' => array($rt_cat_id[0]),
);
}
}