Forums › Forums › Search & Filter Pro › Swap ACF Value and Label in filters
- This topic has 4 replies, 2 voices, and was last updated 4 years, 10 months ago by
Trevor.
Viewing 5 posts - 1 through 5 (of 5 total)
-
Anonymous(Private) July 24, 2020 at 11:50 am #253755
Hi Trevor,
How are you?
Is it possible to create a hook that shows the html input value attributes in form labels instead of the label values, and adds the label value to a new or existing custom html attribute?This is for creating JS tooltips for filter values. I was making something with JS but this seems not possible because of the dynamic handling of item counting at the end of the label value.
Thanks for thinking about this 🙂
RoelandTrevor(Private) July 24, 2020 at 2:17 pm #253764The only hook we have is this, I don’t know if it will let you do what you want?
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
Anonymous(Private) August 3, 2020 at 12:42 pm #254845It works perfect, thanks!
if(!isset($input_object['options'])) { return $input_object; } //now we know there are options we can loop through each one, and change what we need foreach($input_object['options'] as $option) { if($option->value=="") {//the option with no value is always the "all items" or unselected state } else {//we want to change the label for the option "black" - we can feed back in the count number to the label for this field type $option->attributes['title'] = $option->label; $option->label = $option->value ." (".$option->count.")"; } }
-
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)