Anchor Tag that Opens Accordion Element?

Is it possible to set an anchor tag in a specific accordion element, so a link on another page can open the page with the accordion and also open the specific accordion element?

Hi Andrew,

Thanks for reaching out.

You mean the anchor link should open an accordion item based on hash? That’s possible with accordion element (not the classic one), you will have to add the hash to the accordion item, and that hash should be used on the link.

Then you can simply add a link like example.com/page-name/#accordion_hash_here

Thanks!

Thanks! That works, it opens the accordion item, but it doesnt scroll the page to the accordion item. We can live with it, but it would be cool to have the page scroll down to the content.

Hi Andrew,

Scrolling is not an existing feature in this one, hash usually position it directly to target anchor. But please check this thread for scrolling https://theme.co/apex/forum/t/tabbed-content-url-link-to-go-to-a-specific-tab/50220/4. It should work on both tab and accordion anchor.

jQuery (function($){
$(window).load ( function() {  

    if(window.location.hash) {
      var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
     
   
    var header_height =  115 + $('#wpadminbar').height();      
   
    var yloc = $('[data-x-toggle-hash="' + hash + '"]').offset().top - header_height;

    $('html, body').stop().animate({
        scrollTop: yloc
    }, 850);


}
    
} );

});

You can control the offet by changing the 115, it’s usually the header height.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.