[Resolved] smooth-scroll links from other pages

Home Forums Support smooth-scroll links from other pages

  • This topic has 4 replies, 3 voices, and was last updated 11 months ago by Tom.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #1041196

    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>


    Update, If I change the links from
    <a href="/sub-page#section2" >menu link</a>
    <a href="/sub-page/#section2" >menu link</a>
    Then the smooth-scroll works if I’m on the same page.

    However it doesnt smooth-scroll if I’m linking from another page.

    Is this possible?

    Customer Support

    Hi there,

    smooth-scroll will only work on anchors that are on the same page. Not possible to make it apply when navigating to a new page.


    ok, good to know, thanks

    Lead Developer
    Lead Developer

    It may be possible if you use a jQuery smooth scroll script instead of our vanilla javascript smooth scroll script. This might help: https://stackoverflow.com/a/46673487

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