Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

How to add aria-label to logo?

  • Google PageSpeed Insights wants me to add an aria-label=”” to my logo to increase my accessibility score.

    How can I add this in GP or GB?

  • You can use a filter like this:https://docs.generatepress.com/article/generate_logo_output/

    In your case, try this, replace something with the actual aria-label you want to use.

    add_filter( 'generate_logo_output', 'tu_logo_target', 10, 3 );
    function tu_logo_target( $output, $logo_url, $html_attr ) {
    	printf(
    		'<div class="site-logo">
    			<a href="%1$s" title="%2$s" rel="home" aria-label="something"  rel="noopener">
    				<img %3$s />
    			</a>
    		</div>',
    		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		$html_attr
    	);
    }
  • Great, thanks Ying.

    Where do I put this? Functions.php?

  • You can use one of the methods introduced here:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

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