Support » Plugin: A-Z Listing » Smooth Scrolling

  • Resolved algerpixel

    (@algerpixel)


    I would like to know if there’s a way to enable/add smooth scrolling to the A-Z anchor links that appear at the top of the page?

    I’ve tried using several third-party WordPress “Smooth Scrolling” plugins – none of them seem to work with your plugin.

    Any suggestions?
    Thanks much.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • I needed the same thing. I added the following to my A-Z page:

    <script type="text/javascript">
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
    
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
            });
        });
    });
    </script>

    I inserted your JS code at the top of my A-Z page (in source mode) – and it didn’t do anything. Clicking a letter at the top, or clicking “return to top” anywhere down in the page, it does not smooth scroll, but still jumps to the anchors.

    This is the page URL, if you want to have a look..
    https://fredhallswingthing.com/a-z-post-listings

    • This reply was modified 1 year, 4 months ago by algerpixel.

    You might need to place that script tag within the template file and not where you place content. Looks like there is a “p” (paragraph) tag wrapped around the script tag and I’m not sure if that might be interfering with the actual code running.

    Well it does say you can add it to the “text tab” or “source mode” but I’m wondering if the paragraph tag is causing issues. Looking into this now.

    I added a plugin to insert code in the page.
    First I tried inserting it at the top, that didn’t work.
    Then I tried inserting it in the footer instead, THAT worked.

    Many thanks for the solution.

    PS: the plugin I used to insert it is this one..
    https://wordpress.org/plugins/wpc-insert-code/

    Great to hear!! I confirm on my end it’s working as well!!

    Love when things get worked out 😉

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Smooth Scrolling’ is closed to new replies.