Archived topic
PHP for custom back-to-top image stopped working
3 replies · Started by Elizabeth on October 26, 2022
The website that I'm working with is https://www.nagareprivatestudio.com/. I have been using the code below to use a custom back-to-top image in the functions.php file. The back-to-top custom image had been working up until the last week or so. Any suggestions are welcome.
// Custom image in the Back to Top button
add_filter( 'generate_back_to_top_output', 'tu_custom_back_to_top_icon' );
function tu_custom_back_to_top_icon() {
printf(
'
![]()
<span class="screen-reader-text">%5$s</span>
',
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' )
);
}
Hi there,
There's inline style added to the back to top button:
https://www.screencast.com/t/kpGAupAsSkRV
It's not added by GP, can you disable all plugins except GP premium to test?
If you have other custom function, can you try to disable them as well?
Hi Ying,
Thank you for the screenshot of the inline code. The original PHP snippet from this older post, https://generatepress.com/forums/topic/back-to-top-button-change/, had the inline code that was causing the issue. I'm guessing that it used to hide the default back-to-top button.
I removed style="opacity:0;visibility:hidden;" from the original snippet and the custom image is visible again.
Awesome :)