Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add alt tag to featured images
add_filter('wp_get_attachment_image_attributes','tu_featured_image_alt', 10, 2);
function tu_featured_image_alt( $attr, $attachment ) {
remove_filter('wp_get_attachment_image_attributes','tu_featured_image_alt');
$attr['alt'] = $attachment->post_title;
return $attr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment