Tagged: scroll to top
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“
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))){
Thank you Guenni007, it worked as i wanted it.