Created
November 18, 2015 08:28
-
-
Save caralgar/7f8c29abb2deff5b8d79 to your computer and use it in GitHub Desktop.
How to show title on images (general filter) - wp_get_attachment_image
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
<?php | |
add_filter( 'wp_get_attachment_image_attributes', 'add_title_to_attachment_image', 10, 2 ); | |
function add_title_to_attachment_image( $attr, $attachment ) { | |
$attr['title'] = esc_attr( $attachment->post_title ); | |
return $attr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment