Hi there,
We use the below Custom Code to limit the amount of taxonomies in a dropdown. Works great.
However how do we add another View ID? What ever we try breaks this.
To be clear we wish, if possible, to add another ID to this line of code:
if($view_id == 37131 && $taxonomy == 'property-feature'){
Many thanks.
function prefix_modify_get_terms_args( $args, $taxonomy, $view_id ) {
if($view_id == 37131 && $taxonomy == 'property-feature'){
$args['slug'] = array(
'romantic-bolthole',
'fun-family-holiday',
'coastal-village',
'contemporary-interior',
'luxurious-property',
'open-fire',
'hot-tub',
'close-to-coast',
'close-to-shops-pubs',
'close-to-restaurant',
);
}
return $args;
}
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Pete,
You can make use of the in_array function.
Declare the list of ids that you want to check against like this.
$ids = array(37131, 12345, "12354);
Then you would check if the current view ID is in this array.
So your final code should look like.
function prefix_modify_get_terms_args( $args, $taxonomy, $view_id ) {
$ids = array(37131, 12345, "12354);
if(in_array($view_id,$ids) && $taxonomy == 'property-feature'){
$args['slug'] = array(
'romantic-bolthole',
'fun-family-holiday',
'coastal-village',
'contemporary-interior',
'luxurious-property',
'open-fire',
'hot-tub',
'close-to-coast',
'close-to-shops-pubs',
'close-to-restaurant',
);
}
return $args;
}
Thanks,
Shane
My issue is resolved now. Thank you!