Site logo

Archived topic

Adding alt tag to Author images

2 replies · Started by Nicholas on May 24, 2020

Viewing posts 1–3 of 3

Hi there!

I'm trying to add alt tags to the author images on our site. I've been able to do so in a custom author box, but on the author archive pages I'm not sure how I do this.

This is the code I have for the post author box:

<?php

global $post;

?>

<?php $alt = get_the_author_meta('display_name'); ?>

<?php echo get_avatar( get_the_author_meta( 'ID' ), '95', '', $alt ); ?>
<h5 class="author-title"><?php printf( esc_attr__( '%s', 'the author' ), get_the_author_meta( 'display_name') );?></h5>

<p class="author-description"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></p>

So as you can see I use the author name as the alt tag.

When I inspect the author archive images, this is the result:

How can I add a similar alt tag in the archive page?

Thanks!

Thanks for posting the solution! :)

This archived topic is closed to new replies.