
-
AuthorPosts
-
May 2, 2025 at 11:48 am #1483495
Hello,
I have a page with 3 different accordion, each one with an #id.
Actually when I click on each accordion block the clicked section open and the rest close.
I would like to know if this behaviour can be used on the other accordion blocks. So just one exploded section is big in the whole page.Thanks for support
May 2, 2025 at 8:27 pm #1483529Hey SurigliaStudio,
I’m not sure that I understand your question, do you want to open multiple tabs with one click?
Best regards,
RikardMay 3, 2025 at 11:01 am #1483538can you show me the page – it is hard to find the right selectors without the example page.
May 5, 2025 at 10:54 am #1483613Hello, this is the page.
As you can see there are 5 different accordion.
If you click on “PERCORSI” on the “FOOD” accordion it open.
Later on if you click on “CALICE” it open the other accordion and the “PERCORSI” one stay open.
I would like to know if there is a way to make the other accordion close on click on a different one, so I always have a single accordion section open at a time.May 5, 2025 at 11:03 am #1483615put this to your child-theme functions.php:
function only_one_toggle_open_at_the_same_time(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($){ $('.toggler').on('click', function(){ $('.toggler').not(this).next('.toggle_wrap').removeClass('active_tc'); $('.toggler').not(this).removeClass('activeTitle'); }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'only_one_toggle_open_at_the_same_time');
if you like to have that only for that page – use conditional tags – and insert instead:
function only_one_toggle_open_at_the_same_time(){ if ( is_page(719) ) { ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($){ $('.toggler').on('click', function(){ $('.toggler').not(this).next('.toggle_wrap').removeClass('active_tc'); $('.toggler').not(this).removeClass('activeTitle'); }); })(jQuery); }); </script> <?php } } add_action('wp_footer', 'only_one_toggle_open_at_the_same_time');
May 5, 2025 at 5:48 pm #1483632May 8, 2025 at 3:10 pm #1483862Hey Guenni, thanks for your awesome help, as always :)
Have a nice day.
AMay 8, 2025 at 3:58 pm #1483876But you do not use it now?
May 8, 2025 at 4:05 pm #1483877I do, just didn’t clean the cache. Now you should see it correctly :)
-
AuthorPosts
- You must be logged in to reply to this topic.