-
AuthorPosts
-
February 3, 2024 at 7:28 pm #1432888
Hello Enfold team,
My anchor link positioning doesn’t seem to be working quite right. If I click on the menu item “contact us” from the homepage, it works as expected. However, if I click on this menu link from any other page or from hyperlinks that I’ve created the positioning is off.
Clicking the menu item “Contact Us” from http://ntechgrate1.sg-host.com works as intended.
Clicking the menu item “Contact Us” from http://ntechgrate1.sg-host.com/portfolio/ doesn’t scroll far enough.
Clicking the text “Contact Us” from http://ntechgrate1.sg-host.com/the-franz/ doesn’t scroll far enough.Any ideas here?
Thanks
-JamesFebruary 5, 2024 at 4:31 am #1432966Hey James,
Thank you for the inquiry.
The home page loaded correctly on our end, but the subpages didn’t — they showed a broken layout with no styles. Have you installed any third-party compression plugins? Please disable the cache and compression plugins temporarily.
Best regards,
IsmaelFebruary 5, 2024 at 5:30 am #1432970Ok, I cleared the cache on the server and disabled all compression and cache plug-ins.
February 6, 2024 at 5:36 pm #1433307Hi,
I added this function in your child theme functions.php to allow your page to fully load, and then scroll to anchor so the height of elements while loading doesn’t change the anchor possession.function custom_slow_scroll_script() { ?> <script> (function($) { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - 125 //offsets for fixed header }, 2000); return false; } } }); //Executed on page load with URL containing an anchor tag. if($(location.href.split("#")[1])) { var target = $('#'+location.href.split("#")[1]); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - 125 //offset height of header here too. }, 2000); return false; } } }(jQuery)); </script> <?php } add_action('wp_footer', 'custom_slow_scroll_script');
This seems to work in my tests, please clear your browser cache and check.
Please note that some browsers may require you to clear the history in order to fully clear the cache.Best regards,
MikeFebruary 20, 2024 at 7:23 pm #1434938Mike,
I am so sorry for my delayed response. I got pulled onto another project and just circled back to this.
Anyway, your code worked great! Please feel free to close this ticket.
Thank you so much.
-JamesFebruary 20, 2024 at 7:52 pm #1434943Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Anchor Link Positioning is Off’ is closed to new replies.