Archived topic
add one more back to top button
3 replies · Started by Roman on October 2, 2017
Hello, how i can add one more back to top button with different link. For example i need a two button with back to top link & link to home page. Any hook for this action ?
Thanks
You would have to build a whole new element and apply similar CSS to it.
You can see how the back to top button is added here: https://github.com/tomusborne/generatepress/blob/1.4/inc/template-tags.php#L669-L692
Thanks,
I have add this to function php
add_action( 'wp_footer','generate_back_to_top_2' );
function generate_back_to_top_2()
{
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
if ( 'enable' !== $generate_settings[ 'back_to_top' ] ) {
return;
}
echo apply_filters( 'generate_back_to_top_output', sprintf(
'<div class="tohome"><a title="%1$s" href="http://sitename.com" class="generate-back-to-top" style="opacity:0;visibility:hidden;" data-scroll-speed="%2$s" data-start-scroll="%3$s">
<i class="fa %4$s" aria-hidden="true"></i>
<span class="screen-reader-text">%5$s</span>
</a></div>',
esc_attr__( 'Scroll back to home','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-left' ) ),
__( 'Scroll back to home','generatepress' )
));
}
It works and display, but if i click to the button, page just scroll up like a to top button and nothing more. I need a open link. How i can do this ?
You would have to remove this class: generate-back-to-top
It's attached to some javascript which makes it scroll to the top.
Removing that class may mean you need to adjust the styling of the button to match the back to top button again. You can just copy the CSS from the other buttons and adjust the class name.