Forums › Forums › Search & Filter Pro › using string to translate text in within filter
- This topic has 25 replies, 3 voices, and was last updated 6 years, 4 months ago by
Trevor.
-
Anonymous(Private) June 19, 2019 at 12:33 pm #214457
I have found this however it as sfid ==12345 what do you use to replace 12345? Would this be a more correct snippet.
function my_plugin_search_filter_change_label($input_object, $sfid) { if ($sfid == 12345 && $input_object['name'] == '_sf_post_type') { foreach ($input_object['options'] as $key => $option) { if ($option->label == 'Media') { $input_object['options'][$key]->label = 'Photos'; } } } return $input_object; } add_filter('sf_input_object_pre', 'my_plugin_search_filter_change_label', 10, 2);
Anonymous(Private) June 19, 2019 at 3:26 pm #214482I have tried it in the functions.php but I cant seem to get it to change word ‘Brochures’ to ‘Test’
This is the code I have used am I missing something?
<?php function my_plugin_search_filter_change_label($input_object, $sfid) { if ($sfid == 845 && $input_object['name'] == '_sft_file_type[]') { foreach ($input_object['options'] as $key => $option) { if ($option->label == 'Brochures') { $input_object['options'][$key]->label = 'Test'; } } } return $input_object; } add_filter('sf_input_object_pre', 'my_plugin_search_filter_change_label', 10, 2); ?>
Ross Moderator(Private) June 19, 2019 at 8:07 pm #214522Hi there
What happens when you echo something inside each
if
statement?if ($sfid == 845 && $input_object['name'] == '_sft_file_type[]') { echo "got here";
And
if ($option->label == 'Brochures') { echo "got in the brochures option";
Do you see them on the front end?
I think also your field name is probably
_sft_file_type
not_sft_file_type[]
Thanks
Anonymous(Private) June 20, 2019 at 9:03 am #214552Hello Yes they both appeared but when I refreshed my browser Brochures got replaced with Test so I removed your echo code I added and it was still there so it must have been some kind of caching issue.
At least I know now the codes works in the correct place. May I ask how I can add multiple text replacements in this?
Thanks
-
AuthorPosts