
-
AuthorPosts
-
March 14, 2025 at 4:39 pm #1479351
Is there a way to have a Tab Section (with ID name/direct URL) open to the tab and also scroll down on the page to where that section is? Right now it’s just opening, but it’s not scrolling down.
March 16, 2025 at 7:39 pm #1479486Hey amyncuih,
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:add_action( 'wp_footer', 'ava_custom_script_tab_section',99 ); function ava_custom_script_tab_section() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($) { function scrollToTab(s, e) { $(s).on(e, function(event) { var anchor, loc, cur, hash, tab, parent, pos; if( e == 'load' ) { loc = window.location.hash; hash = loc; } else { loc = $(this).attr('href'); hash = loc.substring(loc.indexOf('#')); } tab = $('.av-section-tab-title[href="'+ hash +'"]'); parent = tab.parents('.av-tab-section-outer-container'); pos = parent.offset(); tab.trigger('click'); if(hash) { setTimeout( function() { $(window).scrollTop( pos.top - 100 ) }, 100 ); } }); } scrollToTab( '.avia-buttonrow-wrap a', 'click' ); scrollToTab( window, 'load' ); })(jQuery); }); </script> <?php } add_theme_support( 'deactivate_tribe_events_calendar');
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
Best regards,
MikeMarch 18, 2025 at 6:13 pm #1479646Adding that code is giving errors in the footer and it didn’t work.
March 18, 2025 at 9:28 pm #1479659Hi,
Perhaps you copied the code from an email instead of the forum, or you have an error in your child theme functions.php file.
Please include a admin login in the Private Content area so we can examine.Best regards,
MikeMarch 19, 2025 at 9:20 pm #1479752I copied the code from the forum, but please take a look at our functions.php and assist. We are using a child theme. Thank you!
March 20, 2025 at 4:30 pm #1479803March 20, 2025 at 7:06 pm #1479813Thank you Mike! It works perfectly. Could you share some insight on how you added the code to make it work?
March 21, 2025 at 5:45 am #1479836Hi,
The script is the same as the one posted above, so it’s possible that it was not added correctly earlier. https://kriesi.at/support/topic/tab-section-direct-links-for-tabs/#post-1479486
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.