{"id":4482,"date":"2018-01-20T12:41:10","date_gmt":"2018-01-20T11:41:10","guid":{"rendered":"https:\/\/florianbrinkmann.com\/en\/?p=4482"},"modified":"2020-02-09T10:59:38","modified_gmt":"2020-02-09T09:59:38","slug":"closing-a-customize-section-via-js","status":"publish","type":"post","link":"https:\/\/florianbrinkmann.com\/en\/closing-a-customize-section-via-js-4482\/","title":{"rendered":"Closing a customize section via JS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Sometimes it can be helpful to close a section in the WordPress Customizer, for example, after a button was clicked. If you know how to do it, it is really easy to do, but I searched for a while recently until finding the solution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With this one-liner you can close a section:<\/p>\n\n\n<pre class=\"wp-block-code lang-js\" aria-describedby=\"shcb-language-44\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">wp.customize.section(<span class=\"hljs-string\">'hannover_portfolio_archive_page_options'<\/span>).collapse();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-44\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><code class=\"lang-js\">hannover_portfolio_archive_page_options<\/code> is the ID of the section you want to close.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes it can be helpful to close a section in the WordPress Customizer, for example, after a button was clicked. If you know how to do it, it is really easy to do, but I searched for a while recently until finding the solution. With this one-liner you can close a section: hannover_portfolio_archive_page_options is the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wpf_show_in_dewp_planet_feed":false,"flobn_post_versions":"","webmentions_disabled_pings":false,"webmentions_disabled":false,"lazy_load_responsive_images_disabled":false,"footnotes":""},"categories":[115],"tags":[],"class_list":["post-4482","post","type-post","status-publish","format-standard","hentry","category-wordpress-snippets"],"wp-worthy-pixel":{"ignored":false,"public":null,"server":null,"url":null},"wp-worthy-type":"normal","_links":{"self":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/4482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/comments?post=4482"}],"version-history":[{"count":2,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/4482\/revisions"}],"predecessor-version":[{"id":5815,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/4482\/revisions\/5815"}],"wp:attachment":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/media?parent=4482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/categories?post=4482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/tags?post=4482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}