Site logo

Archived topic

Smooth scroll plugin

10 replies · Started by pke on May 21, 2022

Viewing posts 1–11 of 11

Hi
Years ago you gave me the advise to install the plugin. But now:

The plugin code snippets is not anymore supportet by wp.. So how do i get the smooth scrolling? thanks.

I had to put in this snippet:

add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
$elements[] = 'a[href*="#"]';

return $elements;
} );

So how can i have smooth scroll bCk on all the sites,i wish?
Thank you
Pke

Hi no it was not this. The snippes was automaticly delete by wordpress - on several sites. So i do not have it. But anyway. Whats the best way to have smooth scroll again?
Thanks

Hi there,

the Code Snippets plugin was blocked by WordPress due to a false positive.
The plugin has now been approved again and is back on the repository.

So to add that PHP Snippet. You can either:

a. Use the Code Snippets plugin to add it.

OR

b. Use a Child Theme to add it:
https://docs.generatepress.com/article/using-child-theme/

Thanks David
So i can reinstall it.
And the code to put in the plugin ist ist still this (As i am not sure anymore) ??

@@@

add_filter( ‘generate_smooth_scroll_elements’, function( $elements ) {
$elements[] = ‘a[href*=”#”]’;

return $elements;
} );

@@@

Hi again
is this the right code for smooth scroll to put in on Code Snippets ?
Thanks

Sorry for hijacking... But couldn't this native CSS feature do the trick too?

html {
scroll-behavior: smooth;
}

Works for me

Hi Matt,

absolutely correct, and it is a good option, as long as you don't have a sticky navigation that may obscure the jump link ( or want to control its speed or easing function ) . GPs smooth-scroll knows if GPs sticky nav is present and offsets the scroll position to compensate for it. But if you don't use Sticky or the GP back to top then CSS is good :)

Thanks Matt and David
I tried both - but as I use Sticky and the GP back to top i stick to the first solution.
Have a gret day!
pke

Glad to hear that pke!

This archived topic is closed to new replies.