Remove title attribute from WordPress images

I use default WordPress functions to insert images very often. Functions like the_post_thumbnail or wp_get_attachment_image are used in almost every project I do.

By default WordPress adds a title to all of the images printed by these functions, and the title usually is nothing more than the filename.

The result is a lot of title attributes which are pretty much useless and just distracting (while hovering an image for instance).

But thankfully WordPress filters saves us as they often do.

Filter wp_get_attachment_image_attributes and unset the title attribute.

function mytheme_wp_get_attachment_image_attributes( $attr ) {


 return $attr;
add_filter( 'wp_get_attachment_image_attributes', 'mytheme_wp_get_attachment_image_attributes' );

After that you should be set!


Web Developer @ Oakwood Creative -

Tagged with: , , , , ,
Posted in Intermediate
4 comments on “Remove title attribute from WordPress images
  1. Thankfully stumbled on your post and just wanted to take the time to say thank you 🙂
    Saved me quite some time of frustrated hair-pulling there!

  2. rmccastro says:

    Hello Dear Vincent,

    How can i do this, using CSS? I have a account and therefore my only chance of changing this is via CSS editor



  3. James says:

    Where do I put this code in order to make it work, I need to hide all titles on images in a site

  4. James says:

    I have tried adding in footer.php and header but the text just shows in the page and the title is still there,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


WordPress Quick Tips is a blog supplying great tips about WordPress.

We hope to create a great knowledge resource for WordPress developers as well as serving a reminder for all the forgetful ones.

The blog is created and run by Vincent of Oakwood Creative

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 121 other subscribers
%d bloggers like this: