Closing a customize section via JS

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:

wp.customize.section('hannover_portfolio_archive_page_options').collapse();
Code language: JavaScript (javascript)

hannover_portfolio_archive_page_options is the ID of the section you want to close.

Leave a Reply

Your email address will not be published. Required fields are marked *