[Resolved] Site Logo Alt Tag Filter

Home Forums Support [Resolved] Site Logo Alt Tag Filter

Home Forums Support Site Logo Alt Tag Filter

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1232338
    Michael

    Hello Tom,

    I found you posted this code to adjust the Site Logo alt tag independently from the Site Title given in customizer:

    add_filter( 'generate_logo_title', 'tu_adjust_logo_alt' );
    function tu_adjust_logo_alt() {
        return 'Reclaim Design Logo';
    }

    I’ve added this and what happens is that it changes the site link title text as well:

    https://www.dropbox.com/s/92eq3833b8k7ted/site-logo-alt-tag.jpg?dl=0

    How can I set the filter to only add alt tag for the image and keep the site link title as it is set in Customizer?

    So <a href="https://reclaimdesign.org/" title="Reclaim Design" rel="home"> instead of <a href="https://reclaimdesign.org/" title="Reclaim Design Logo" rel="home"> (as it’s getting set to when the filter is applied)?

    Thank you for your help πŸ™‚

    Michael.

    #1232900
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You can do this:

    add_filter( 'generate_logo_output', function( $output, $logo_url, $html_attr ) {
    	printf(
    		'<div class="site-logo">
    			<a href="%1$s" title="Set your title here" rel="home">
    				<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
    	);
    }, 10, 3 );
    #1232989
    Michael

    You’re the bomb Tom – that works great, thank you! πŸ™‚

    #1233349
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

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