By default, the “All” option is active for the Checkbox, Radio, Dropdown, Button types of Live Filter.
To activate another option at the beginning, you can use one of 2 solutions below:
1. Please add the view to the page where you want to show it.
Visit the page, select the option that you want to set as default.
Copy the URL in browser’s address bar and use it as the link to the page.
2. Or there is another way.
Please add this code to Custom JS field in Content Views >> Settings page:
/* Live Filter - set default filter */ function cvp_lf_default_option(term_slug, view_id){ if (!window.location.search) { var $el = $('[value="' + term_slug + '"]', '[data-sid="' + view_id + '"]'); $($el).attr("checked", true); $($el).attr("selected", true); $($el).trigger('change'); } }; // duplicate the below line for another view, and change values respectively cvp_lf_default_option('DEFAULT_VALUE', 'VIEW_ID');
then:
- replace
DEFAULT_VALUE
with the value you want to select by default.
To find the right value, please follow these steps:
+ open the page with Live Filter
+ select the option that you want to select by default
+ the URL in browser’s address bar will be changed accordingly and end with:/?NAME=VALUE
+ copy the
VALUE
to replace theDEFAULT_VALUE
in the code.For example, you show categories as filters and want to select the “Business” option by default.
When you select that option, the URL ends with:/?tx_category=business
Then you should usecvp_lf_default_option('business', 'VIEW_ID');
- replace
VIEW_ID
with ID of your View.
Best regards,