{"id":2311,"date":"2017-10-10T01:54:35","date_gmt":"2017-10-10T01:54:35","guid":{"rendered":"http:\/\/docs.contentviewspro.com\/?p=2311"},"modified":"2025-04-03T08:58:04","modified_gmt":"2025-04-03T08:58:04","password":"","slug":"live-filter-set-default-filter-activate-filter-beginning","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/live-filter-set-default-filter-activate-filter-beginning\/","title":{"rendered":"Live Filter &#8211; set default active filter"},"content":{"rendered":"<p>By default, the &#8220;All&#8221; option is active for the Checkbox, Radio, Dropdown, Button types of Live Filter.<br \/>\nTo activate another option at the beginning, you can use one of 2 solutions below:<\/p>\n<p>1. Please add the view to the page where you want to show it.<br \/>\nVisit the page, select the option that you want to set as default.<br \/>\nCopy the URL in browser&#8217;s address bar and use it as the link to the page.<\/p>\n<p>2. Or there is another way.<br \/>\nPlease add this code to <strong>Custom JS<\/strong> field in Content Views &gt;&gt; Settings page:<\/p>\n<pre style=\"font-size: 13px;\">\/* Live Filter - set default filter *\/\nfunction cvp_lf_default_option(term_slug, view_id){\n    if (!window.location.search) {\n        var $el = $('[value=\"' + term_slug + '\"]', '[data-sid=\"' + view_id + '\"]');\n        if ($el.length) {\n        $el.attr(\"checked\", true);\n        $el.attr(\"selected\", true);\n        $el.trigger('change'); \n        \/\/ let event = new Event('change'); $el[0].dispatchEvent(event);\n        }\n    }\n};\n\/\/ duplicate the below line for another view, and change values respectively\ncvp_lf_default_option('DEFAULT_VALUE', 'VIEW_ID');\n<\/pre>\n<p>then:<\/p>\n<ul>\n<li>replace <code>DEFAULT_VALUE<\/code> with the value you want to select by default.<br \/>\nTo find the right value, please follow these steps:<br \/>\n+ open the page with Live Filter<br \/>\n+ select the option that you want to select by default<br \/>\n+ the URL in browser&#8217;s address bar will be changed accordingly and end with:<\/p>\n<pre style=\"font-size: 13px;\">\/?NAME=VALUE\n<\/pre>\n<p>+ copy the <code>VALUE<\/code> to replace the <code>DEFAULT_VALUE<\/code> in the code.<\/p>\n<p>For example, you show categories as filters and want to select the &#8220;Business&#8221; option by default.<br \/>\nWhen you select that option, the URL ends with: <code>\/?tx_category=business<\/code><br \/>\nThen you should use <code>cvp_lf_default_option('business', 'VIEW_ID');<\/code><\/li>\n<li>replace <code>VIEW_ID<\/code> with <a href=\"https:\/\/contentviewspro.com\/documentation\/article\/what-is-id-of-a-view\/\">ID of your View<\/a>.<\/li>\n<\/ul>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, the &#8220;All&#8221; 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 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/live-filter-set-default-filter-activate-filter-beginning\/\"> <span class=\"screen-reader-text\">Live Filter &#8211; set default active filter<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[46],"doc_tag":[35],"class_list":["post-2311","docs","type-docs","status-publish","hentry","doc_category-live-filter","doc_tag-live-filter"],"year_month":"2026-09","word_count":282,"total_views":"1","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"CVP","author_nicename":"cvp","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/cvp\/"},"doc_category_info":[{"term_name":"Live Filter (Frontend Search &amp; Filter)","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/live-filter\/"}],"doc_tag_info":[{"term_name":"live filter","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/live-filter\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=2311"}],"version-history":[{"count":7,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2311\/revisions"}],"predecessor-version":[{"id":6119,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2311\/revisions\/6119"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=2311"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=2311"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=2311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}