Forums › Forums › Search & Filter Pro › Change Post Type labels
- This topic has 3 replies, 2 voices, and was last updated 8 years, 9 months ago by Ross.
-
Anonymous(Private) March 21, 2016 at 12:06 pm #39990
Hello there,
I would like to be able to modify the label of some post types… for example I don’t like the post type Media to be called Media and would like it to be called Photo on the Search input filter.
Could you be so kind to address me on how to change the labels?
Thank you!
Ross Moderator(Private) March 21, 2016 at 12:50 pm #39999Hi Daniel
In general I think the ideal scenario is to change the label of the post type itself – if that is not possible (in the case of Media), S&F has a filter which allows you to filter the options of any input object:
Be sure to check the github example too for how to change the label of an option.
Thanks
Anonymous(Private) March 21, 2016 at 1:07 pm #40004Perfect,
I’ve done it… it works great. Thank you!
For someone curious about how to implement this, on your plugin php add the following function:
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);
Hope it helps.
-
AuthorPosts