[Resolved] Back to Top

Home Forums Support [Resolved] Back to Top

Home Forums Support Back to Top

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #334514
    mor

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

    Thanks!

    #334529
    Leo
    Staff
    Customer Support

    Hi there,

    Pretty sure this is what you are looking for: https://docs.generatepress.com/article/generate_back_to_top_icon/

    Let me know πŸ™‚

    #334546
    mor

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

    #334564
    Leo
    Staff
    Customer Support
    #334565
    Tom
    Lead Developer
    Lead Developer

    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' )
    	);
    }
    #334566
    Tom
    Lead Developer
    Lead Developer

    Updated that link on gist too, thanks Leo. Overwriting functions is bad, filters are good πŸ™‚

    #334569
    mor

    Thank you! I’m glad I could help πŸ™‚

    #334574
    Leo
    Staff
    Customer Support

    Thanks Tom πŸ™‚

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