Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #716981

    Hi
    I use several accordion shortcode in the same page. I would like that all the toogle close when I open another one, even those of another accordion.

    Thank you for your help

    #717004

    Hey stefanos,

    Unfortunately it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However if its really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Basilis

    #717011

    try this here – maybe it works for you (in child-theme functions.php)

    function only_one_toggle_open_at_the_same_time(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
        	$('.toggler').on('click', function(){
      		$('.toggler').not(this).next().removeClass('active_tc');
    	});
        	$('.toggler').on('click', function(){
                    $('.toggler').not(this).removeClass('activeTitle');	
    	});
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'only_one_toggle_open_at_the_same_time');

    by the way : the laurels go to Josue
    see also here: https://kriesi.at/support/topic/single-toggles-besides-sibblings-each-other/

    • This reply was modified 7 years, 11 months ago by Guenni007.
    #717674

    Perfect !
    That works very well !
    thank you very much

    #717716

    this is now the global solution if you don’t like it for the whole wordpress installation you have to set up some if-clauses

    f.e:

    function only_one_toggle_open_at_the_same_time(){
    if ( is_page(3423) ) {
    ?>
    <script>
    (function($){
        $(window).load(function() {
        	$('.toggler').on('click', function(){
      		$('.toggler').not(this).next().removeClass('active_tc');
    	});
        	$('.toggler').on('click', function(){
                    $('.toggler').not(this).removeClass('activeTitle');	
    	});
        });
    })(jQuery);
    </script>
    <?php
    }
    }
    add_action('wp_footer', 'only_one_toggle_open_at_the_same_time');

    on that if clause you can use all conditional tags you know e.g:

    if ( is_singular( 'event' ) || is_search() || is_category() || is_page() && !is_page(1307) || is_singular( 'portfolio' ) )

    etc.pp

    by the way is_home( ) does not work ??? but: is_front_page( ) works

    PPS: again something new to me :
    is_home() returns only true if it is the blog-post index site
    if your landing-page is a page you have to use is_front_page()

    • This reply was modified 7 years, 11 months ago by Guenni007.
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.