[Resolved] Remove title attribute from logo

Home Forums Support [Resolved] Remove title attribute from logo

Home Forums Support Remove title attribute from logo

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #669736
    Dan

    Hello,
    How can I filter out the title attribute from the logo?
    I don’t want the small tooltip to show up once hovering over the image.

    The action hook is this (inside inc/structure/header.php)

    $attr = apply_filters( 'generate_logo_attributes', array(
    			'class' => 'header-image',
    			'alt'	=> esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    			'src'	=> $logo_url,
    			'title'	=> esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		) );
    

    Thanks,
    Dan

    #669745
    Leo
    Staff
    Customer Support

    Hi Dan,

    Give this filter a shot:
    https://docs.generatepress.com/article/generate_logo_output/

    Let me know if this helps ๐Ÿ™‚

    #669782
    Dan

    Thanks Leo,
    I modified the filter a bit to this (to remove the title attribute):

    add_filter( 'generate_logo_output', 'tu_no_logo_title', 10, 3 );
    function tu_no_logo_title( $output, $logo_url, $html_attr ) {
    	printf(
    		'<div class="site-logo">
    				<a href="%1$s" rel="home">
    					<img %3$s />
    				</a>
    			</div>',
    		$html_attr
    	);
    }

    but it removed the logo altogether.
    Still, I don’t see where it removes the ‘title’ from the img tag.

    Dan

    #669794
    Leo
    Staff
    Customer Support

    What if you simply remove the site title from Site Identity in the customizer?

    #669797
    Leo
    Staff
    Customer Support
    #670213
    Dan

    Thanks Leo,
    The last solution did the trick as I didn’t want to remove the title completely from the site.

    Dan

    #670376
    Leo
    Staff
    Customer Support

    No problem ๐Ÿ™‚

    #758979
    Michael

    I’m also trying to remove or change the title attribute text from the img tag in the site logo. The issue is that the alt-text and the title are the same, which generates an accessibility error.

    When I use the second fix,

    add_filter( 'generate_logo_title', 'lh_remove_logo_alt' );
    function lh_remove_logo_alt() {
        return '';
    }

    or anything with the ‘generate_logo_title’ filter it removes both the alt-text and the title attribute, which creates the more serious “no alt-text” error.

    Is there a way to remove the title text without affecting the alt-text?

    #759389
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this:

    add_filter( 'generate_logo_attributes', function( $atts ) {
        unset( $atts['title'] );
    
        return $atts;
    } );
    #759417
    Michael

    That did the trick perfectly! Thank you so much!

    Is there a similar snippet/filter for the navigation search? The title on the <li> tag is the same as the screen reader text inside.

    Thanks again!

    #759506
    Leo
    Staff
    Customer Support

    Can you open a new topic for the separate question?

    Thanks!

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