Forums › Forums › Search & Filter Pro › Set Default Radio box checked to different category
Tagged: Category radio box, V3
- This topic has 10 replies, 3 voices, and was last updated 5 years, 8 months ago by Ross.
-
Anonymous(Private) February 26, 2019 at 6:12 am #203242
Hi,
I have categories in a radio box fields but they have only styling of checkboxes functionality wise they work as radio box, I want to set radio box checked to different category as a default at present it set default to all categories i want to set radio box checked to WordPress themes as a default, is there a way to achieve this
Please have a look at attached video url link
url of site: url
Thanks
Trevor(Private) February 26, 2019 at 7:26 am #203245I understand what you need, and it has been asked for before. It is possible to set the default, but it does not alter the results shown until a search is done. V3 should have the option of setting the default and it affecting the results.
The problem with setting the default is that the same code (it has to be done either with JavaScript post page load, or by PHP pre-form load using our filter input objects filter) tends to override any choices made by the user.
Ross Moderator(Private) February 26, 2019 at 1:22 pm #203304Hi there
I understand the scenario.
We have a filter, to change the default in the search form, but this won’t affect the results.
This would be the code (untested ofc):
function filter_input_object_categories($input_object, $sfid){ //ensure we are only filtering the correct field name - in this case the field we want to filter has the name <code>_sft_marketplace</code> if($input_object['name']!='_sft_marketplace'){ return $input_object; } //manually set the values shown/selected in the field - must be array even if single value //this should really only occur under specific conditions, otherwise your field will be permanently set to this value //if the field is not already in use / selected if(!isset($_GET['_sft_marketplace'])){ //then set it to "best wordpress app themes" $input_object['defaults'] = array("best-wordpress-app-themes"); } return $input_object; } add_filter('sf_input_object_pre', 'filter_input_object_categories', 10, 2);
Thanks
Ross Moderator(Private) March 1, 2019 at 10:45 am #203662Hi there
Do you mean the results do not reflect the new “default” we are setting?
Thanks
-
AuthorPosts