1. Home
  2. Knowledge Base
  3. WooCommerce Product Add Ons Ultimate
  4. Set accordion layout to closed
  1. Home
  2. Knowledge Base
  3. Product Page
  4. Set accordion layout to closed
  1. Home
  2. Knowledge Base
  3. Front End
  4. Set accordion layout to closed
  1. Home
  2. Knowledge Base
  3. Pro
  4. Set accordion layout to closed

Set accordion layout to closed

If you’re using the Pro version, you can choose an ‘accordion’ layout for your groups. By default, the first group is open and the others are closed.

You can change this so that all accordion groups start off as closed (or open) using the following snippet.

<?php
/**
* Set all groups to closed (or open) in an accordion
*/
function prefix_filter_initial_accordion_states( $state, $post_id ) {
return 'closed'; // Comment this out and uncomment the line below to set all groups to open
// return 'open';
}
add_filter( 'pewc_filter_initial_accordion_states', 'prefix_filter_initial_accordion_states', 10, 2 );

Follow these steps to add a snippet to your site.

Was this article helpful?

Related Articles