Live Filter – set default filter (activate a filter at the beginning)

By default, the “All” option is active for the Checkbox, Radio, Dropdown, Button types of Live Filter.
To activate another option for these types at the beginning, please add this code to Custom JS field in Content Views >> Settings page:

var term_slug = 'TERM_SLUG_HERE', view_id = 'VIEW_ID_HERE';
var $el = $('[value="' + term_slug + '"]', '[data-sid="' + view_id + '"]');
$($el).attr("checked", true);
$($el).attr("selected", true);
$($el).trigger('change');

then:

  • replace TERM_SLUG_HERE with the slug of the category, tag or taxonomy term you want to activate.
    For example, to find the slug of a category, go to Posts > Categories, you will see the slug of a category in the Slug column:
    WordPress category slug
  • replace VIEW_ID_HERE with ID of your View.

Best regards,