Site logo

Archived topic

Back to Top

7 replies · Started by mor on June 16, 2017

Viewing posts 1–8 of 8

How do I replace the Back-to-Top button with an image (svg if possible)?

Thanks!

If I want to use my own image, will the return be the url?

Actually, you would do this:

add_filter( 'generate_back_to_top_output', 'tu_custom_back_to_top_icon' );
function tu_custom_back_to_top_icon() {
    printf(
		'<a title="%1$s" rel="nofollow" href="#" class="generate-back-to-top" style="opacity:0;visibility:hidden;" data-scroll-speed="%2$s" data-start-scroll="%3$s">
			<img src="URL TO YOUR IMAGE" alt="Back to top" />
			<span class="screen-reader-text">%5$s</span>
		</a>',
		esc_attr__( 'Scroll back to top','generatepress' ),
		absint( apply_filters( 'generate_back_to_top_scroll_speed', 400 ) ),
		absint( apply_filters( 'generate_back_to_top_start_scroll', 300 ) ),
		esc_attr( apply_filters( 'generate_back_to_top_icon','fa-angle-up' ) ),
		__( 'Scroll back to top','generatepress' )
	);
}

Updated that link on gist too, thanks Leo. Overwriting functions is bad, filters are good :)

Thank you! I'm glad I could help :)

Thanks Tom :)

This archived topic is closed to new replies.