Skip Navigation

[Resolved] Add another View ID to Custom Code

This support ticket is created 2 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Pete 2 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#2330357

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;

}

#2330403

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.

in_array($view_id,$ids)

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

#2330933

My issue is resolved now. Thank you!