Forums › Forums › Search & Filter Pro › Default value select
Tagged: default select value, V3
- This topic has 5 replies, 4 voices, and was last updated 2 years, 8 months ago by Anonymous.
-
Anonymous(Private) September 23, 2020 at 8:03 am #260428
Is there ability to change default select value of a filter, instead of all categories, show second option, without queries??
i only found how to exclude option from a list but it still returns all the posts of the custom post type, i need it to select 2nd option on load and leave url as it is, messing with code on github –
filter_function_name($input_object, $sfid){
}how to achieve this?
Thanks.Anonymous(Private) September 23, 2020 at 8:41 am #260434i`m using unset to delete first two option values but i need it to be default, how to do this?? thanks
function filter_function_name($input_object, $sfid)
{
if($input_object[‘name’]==’_sft_tax_news’)
{
/*foreach($input_object[‘options’] as $option)
{
if($option->value==”maironio-lietuviu-literaturos-muziejus”)
{
$option->label = “AAA”;
$option->attributes[‘class’] = “sf-option-active”;
$option->attributes[‘selected’] = “selected”;
}
}*/
unset($input_object[‘options’][0]);
unset($input_object[‘options’][1]);
return $input_object;
//udpate this field before rendering
}
else{
echo “NOOO!”;
return $input_object;
}
}
add_filter(‘sf_input_object_pre’, ‘filter_function_name’, 10, 2);filter_function_name(array(‘name’ => ‘_sft_tax_news’),17402);
-
AuthorPosts