Display Posts uses the standard WordPress core function for displaying the image. If you would like to automatically add an alt tag to images that are missing it, you’ll need to apply this to all images in WordPress.
I haven’t tried any of these, but here are a few tutorials:
– https://isabelcastillo.com/add-title-attribute-wordpress-image-thumbnail
– https://brutalbusiness.com/automatically-set-the-wordpress-image-title-alt-text-other-meta/
Thread Starter
Jochen
(@tadama)
Hi Bill, thanks for the quick response! I would prefer not to touch the media library as I work with user generated content. For the archive page we use this snipplet to add the alt tag based on the title of the post. Would something of that sort also work for your gallery? (I am not a developer, its might be an easy change?)
/**
* Set alt value to post title for featured images in content archives
*/
function sk_set_alt_post_title( $attributes ) {
$attributes[‘alt’] = the_title_attribute( ‘echo=0’ );
return $attributes;
}
add_filter( ‘genesis_attr_entry-image’, ‘sk_set_alt_post_title’ );
Unfortunately no, that wouldn’t work. You’re using a genesis filter to modify a Genesis function, and Display Posts does not use that Genesis function.
The first tutorial I linked to above uses the exact same code as yours but applies it to images using the standard WordPress functions for displaying images.