Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1301399

    Hi,

    I found this code to expand multiple accordeons at once on pageload and copied in QUICK CSS.
    Works great, but affects now all accordeons on all pages, but I waant this to happen on just one page

    .js_active .toggle_wrap {
    display: block;
    position: static;
    visibility: visible;
    left: 0;
    width: auto;
    z-index: 1;
    }

    is there a solution for jus6 a specific page?

    Thank you very much!

    Best,
    Tom

    #1301451

    Hey thomaszechmhx,

    Please provide a link to the site/page in question so we can look into this further.

    Best regards,
    Jordan Shannon

    #1301574
    This reply has been marked as private.
    #1301863

    Hi,
    Thank you for your patience and the link to your page.
    For your first question on how to get the CSS to only work on the one page, you would add the page ID to the CSS like this:

    .js_active .page-id-2575 .toggle_wrap {
    display: block;
    position: static;
    visibility: visible;
    left: 0;
    width: auto;
    z-index: 1;
    }

    Each page has a unique page ID, now the reason you can not close the toggles is because the CSS has been set and clicking the toggles doesn’t change the state and the only way around this is by removing the CSS and writing a jQuery script to replace it.
    I wrote this and it works when I inject it via the browser and it should work when it’s added to your functions.php

    function custom_script() { ?>
        <script>
    (function($){
      $(document).ready(function(){
        $('#top.page-id-2575 .togglecontainer.enable_toggles').each(function() {
        $(this).find( '.toggle_wrap' ).css({'display':'block','visibility':'visible','position':'static','left':'0','width':'auto','z-index':'1'});
    });
    });
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_script');

    But in your theme options you have the “Load jQuery in your footer” option set so this will not work on your site because jQuery has to be loaded before the script for the script to work. I assume that you are trying to set your site to run the fastest so you will need to decide if giving up page load is worth closing the toggles, and if any of your visitors are ever going to try to close your toggles?
    But at least you know the answer now.

    Best regards,
    Mike

    #1302264
    This reply has been marked as private.
    #1302294

    Hi,

    Thanks we’ll await your response.

    Best regards,
    Jordan Shannon

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