[Support request] add one more back to top button

Home Forums Support [Support request] add one more back to top button

Home Forums Support add one more back to top button

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #395953
    Roman

    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 ?

    attach for example

    Thanks

    #396249
    Tom
    Lead Developer
    Lead Developer

    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

    #397196
    Roman

    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 ?

    #397719
    Tom
    Lead Developer
    Lead Developer

    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.

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