How to add title on Featured Image for GeneratePress Theme

Share Now

add_filter( 'wp_get_attachment_image_attributes', 'tl_add_img_title', 10, 2 );
// Add title attribute to featured image
function tl_add_img_title( $attr, $attachment = null){
	$attr['title'] = get_post( $attachment->ID )->post_title;
	return $attr;
}
Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert