Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/14851417f7bcc7620737e2e22d2c2f98 to your computer and use it in GitHub Desktop.
Save generatepress/14851417f7bcc7620737e2e22d2c2f98 to your computer and use it in GitHub Desktop.
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