Site logo

Archived topic

Problem with Smooth Scroll and Table of Contents Plugin

3 replies · Started by lerschiboi on June 28, 2022

Viewing posts 1–4 of 4

Hi,
I found this snippet in this forum to enable smooth-scroll for all elements of my site including buttons:

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

However, I just noticed that it interferes with the show/hide toggle of my table of contents plugin (LuckyWP Table of Contents). When clicking the toggle, it scrolls up to the top of the page. How can I fix this?

Hi there,

in the code try changing:

a[href*="#"]

to:

a:not([class*="lwptoc"])[href*="#"]

Wonderful, that did the trick! :)

Glad to hear that!

This archived topic is closed to new replies.