Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #949161

    Hello,

    on my website I have the following script running (it is needed on some of the pages where I want to have all accordions expanded on page load, not on all pages):

    
    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
         jQuery("p.toggler").trigger('click');
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script'); 
    

    in combination with the accordion setting “Multiple toggles open allowed”, like it is suggested here:

    https://kriesi.at/support/topic/how-do-i-set-accordion-to-have-all-toggles-open-by-default-and-not-only-one/ .

    But I also have a page to which one comes with the link http://www.privatedata.com/somepagetitle#toggle-id-3 , so that the accordion #3 should be directly displayed expanded and others should stay closed. The above script unfortunately closes this accordion #3 as soon as the page gets loaded. How to adjust the script?

    Best regards

    #950460

    Hey med,

    Try adjusting the script like this:

    
    function add_custom_script(){
    	if (is_page(5832)) { return; }
    ?>
         <script>
         jQuery(window).load(function(){
             jQuery("p.toggler").trigger('click');
         });
        </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script'); 
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

    • This reply was modified 6 years, 6 months ago by Victoria.
    #951004

    Thank you Victoria x

    #951418

    Hi med,

    Glad that Victoria helped you. :)
    Let us know if you need further assistance or if we can close this thread.

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.