Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1290047

    Hi,

    How can i change the scroll to top button link, so it will scroll to a specific anchor tag on the page, like a contact form?
    – And can i add a text above it, like “Get in touch

    #1290098

    please try this in your child-theme functions.php:

    function change_scroll_top_link(){
    ?>
    <script type = "text/javascript">
    (function($){
    	$('#scroll-top-link').attr('href', '#newID');
    	$('#scroll-top-link').attr('title', 'Get in touch');
    	$('#scroll-top-link .avia_hidden_link_text').text('Get in touch').css({
    		'display': 'block',
    		'position': 'absolute',
    		'top': '-40px',
    		'left': '-40px',
    		'width': '120px',
    		'font-size': '14px',
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action( 'wp_footer', 'change_scroll_top_link' );

    But: maybe it is enough if you have the title to have “Get in touch” – and to have that on hover
    Then remove the css part

    if you had to do it only for one page:

    function change_scroll_top_link(){
    if(is_page(5)){
    ?>
    <script type = "text/javascript">
    (function($){
            // same as above
    })(jQuery);
    </script>
    <?php
    }
    }
    add_action( 'wp_footer', 'change_scroll_top_link' );

    or for more than one page replace it with an array of pages
    if(is_page(array( 1396, 1617, 1629))){

    #1290124

    Thank you Guenni007, it worked as i wanted it.

    • This reply was modified 3 years, 8 months ago by mvi.
    #1290134

    Hi,

    Glad @Guenni007 could help!

    Thanks for your help as always @Guenni007 :)

    Best regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Scroll to top button – Change it to a specific section’ is closed to new replies.