This is how you remove image titles on hover for your WordPress website.
Just put this code into the function.php file and wallaah, you got it!! Now go forth and create.
/* Remove Image Title on Hover - Start */
add_filter( 'the_content', 'remove_images_title_attribute' );
function remove_images_title_attribute( $text ) {
// Get all title attribute tags
$result = array();
preg_match_all( '|title="[^"]*"|U', $text, $result );
// Replace all title tags with an empty string
foreach ( $result[0] as $image_tag ) {
$text = str_replace( $image_tag, '', $text );
}
return $text;
}
/* Remove Image Title on Hover - End*/
Sincerely,
Sir, Doogie Howser.
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.