If I’m linking to parts of a page using anchor links, is it possible to smooth scroll to the section in question if coming from another page?
The reason I ask is that I have a menu that appears on multiple page with links to parts of the page, but the links are absolute, eg href=”/sub-page#section2″
I looked at adding the code previously mentioned:-
add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
$elements[] = 'a[href*="#"]:not(.generate-back-to-top)';
return $elements;
} );
but I don’t think this would work on links such as
<a href="/sub-page#section2" >menu link</a>