[Support request] Use code to get screen reader text on skip link, now I have two Skip links

Home Forums Support [Support request] Use code to get screen reader text on skip link, now I have two Skip links

Home Forums Support Use code to get screen reader text on skip link, now I have two Skip links

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1541494
    Alicia

    This is totally weird. I got this code here on the forum and it looks like it should remove the original skip link but it’s not. So now I have two!

    remove_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 );
    
    add_action( 'generate_before_header', function() {
        printf( '<a class="screen-reader-text skip-link" href="#content">%s</a>',
            esc_html__( 'Skip to content', 'generatepress' )
        );
    }, 2 );

    Is it a priority issue? I see them both before the header, too.

    #1541501
    Elvin
    Staff
    Customer Support

    Hi,

    Try this PHP snippet instead:

    add_filter('after_setup_theme', function(){
    
    remove_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 );
    
    add_action( 'generate_before_header', function() {
        printf( '<a class="screen-reader-text skip-link" href="#content">%s</a>',
            esc_html__( 'Skip to content', 'generatepress' )
        );
    }, 2 );
    });
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.