Forums › Forums › Search & Filter Pro › using string to translate text in within filter
- This topic has 25 replies, 3 voices, and was last updated 5 years, 4 months ago by Trevor.
-
Trevor(Private) June 19, 2019 at 12:17 pm #214453
Co authors plus is a plugin that allows more than one author of a post. That paricualr author needed to add more authors to the list. It would not be relevant to you, except to, as all snippets may, offer some ideas. In your case, you are not trying to delete an option, merely to change its label.
Anonymous(Private) June 19, 2019 at 12:33 pm #214457I 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
-
AuthorPosts