Created
May 25, 2017 07:32
-
-
Save generatepress/14851417f7bcc7620737e2e22d2c2f98 to your computer and use it in GitHub Desktop.
Add alt tag to featured images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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