[Resolved] Enable Smooth Scroll for all anchor links

Home Forums Support [Resolved] Enable Smooth Scroll for all anchor links

Home Forums Support Enable Smooth Scroll for all anchor links

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #827014
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    That’s strange. It goes away when smooth scroll is turned off?

    #827038
    YSK

    If I do not use “generate_smooth_scroll_elements”, there is no problem.

    Also, there is no problem when using smooth-scroll class for a tag.

    #827529
    Tom
    Lead Developer
    Lead Developer

    Can you share the filter you’re using?

    #827805
    YSK

    I am using a Code Snippets plugin.

    For the test, I only use the following filters.

    https://docs.generatepress.com/article/generate_smooth_scroll_elements/

    add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
      $elements[] = 'a[href*="#"]';
      
      return $elements;
    } );
    #827839
    Tom
    Lead Developer
    Lead Developer

    Try this instead:

    add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
      $elements[] = 'a[href*="#"]:not(.generate-back-to-top)';
      
      return $elements;
    } );
    #827841
    YSK

    I am glad to inform you that the problem is now solved!

    I appreciate your help.

    #827878
    Tom
    Lead Developer
    Lead Developer

    Awesome! Glad I could help 🙂

    #2216341
    Annamari

    Hi!

    Has this code changed? I’d like to use it but instead of working, it adds a question mark to my URL…

    #2216734
    Ying
    Staff
    Customer Support

    Hi Annamari,

    The code should still work.

    Can you open a new topic and link us to the page where we can see the link?

Viewing 9 posts - 16 through 24 (of 24 total)
  • You must be logged in to reply to this topic.