Site logo

[Resolved] Forced auto-scroll on certain page

Home Forums Support [Resolved] Forced auto-scroll on certain page

Home Forums Support Forced auto-scroll on certain page

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #539207
    Carol

    What is the best way to force the page to load exactly below the top header and navigation? Here is the page I’m working on: https://ncsfa.site/convention-2018/

    What I’m trying to do is have the page load with only the slider showing on the viewpoint. The user will have to scroll up to see the top header content.

    I’ve tried to insert an elementor anchor at the top of the slider with a class of slider-top. But I don’t know how to link to this page anchor on page load.

    Any help would gladly be appreciated.

    #539296
    Tom
    Lead Developer
    Lead Developer

    You could try to use javascript.

    Something like this in the wp_footer hook might work:

    <script>
    jQuery(document).ready(function ($) {
        $('html, body').scrollTop( 300 );
    });
    </script>

    300 being the height in pixels to start the page at.

    #540003
    Carol

    Yes, but wouldn’t that be applied to all pages? And what if I’m already using a elementor template shortcode in that gp hook position? Isn’t there a way to apply this only to that particular page id# ?

    #540504
    Tom
    Lead Developer
    Lead Developer

    You could use PHP for that:

    <?php if ( is_page( 'your-page-slug' ) ) : ?>
        <script>
            jQuery(document).ready(function ($) {
                $('html, body').scrollTop( 300 );
            });
        </script>
    <?php endif; ?>
    #542468
    Carol

    <?php if ( is_page( ‘convention-2018’ ) ) : ?>
    <script>
    jQuery(document).ready(function ($) {
    $(‘html, body’).scrollTop( 300 );
    });
    </script>
    <?php endif; ?>

    Inserted that in the wp_footer hook but it works on ALL pages, not just the https://ncsfa.site/convention-2018/ page. Since we haven’t promoted this yet, I’ll leave it until you see it.

    #545750
    Carol

    Any more thoughts on how to do this?

    #545944
    Tom
    Lead Developer
    Lead Developer

    Sorry about this! Not sure how I missed your reply.

    Did you check the “Execute PHP” checkbox in that hook?

    #546727
    Carol

    That box was hidden. iThemes security had added the disable line in the config file. Tweaked the security, removed the line, logged out, logged back in, checked the box and voila! Working like a champ. You’re the best.

    Thanks

    #546819
    Tom
    Lead Developer
    Lead Developer

    Awesome, no problem 🙂

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