I'm currently adding thumbnails to my page with: <?php the_post_thumbnail( 'category-thumb' ); ?> and this in the fuctions.php:

if ( function_exists( 'add_image_size' ) ) {
    add_image_size( 'category-thumb', 200, 142 );

How do i stop the title tag from being added?

  • Why do you want to get rid of it? – kaiser Oct 24 '12 at 1:19
  • @kaiser because i only want the src, alt, height, and width – Joe Bobby Oct 24 '12 at 2:34
  • That's exactly no explanation. I was asking for a reason and you're telling me your task... – kaiser Oct 24 '12 at 10:54

This filter will remove it completely from all images, you can add a conditional to only effect certain images.

function remove_img_title($atts) {
    return $atts;

Instead if you want to use <?php the_post_thumbnail( 'category-thumb' ); ?>

You can pass it an empty title using the second $attr so your title tag will look like title=" ".

It would be:

$default_attr = array('title'   =>  ' ');
the_post_thumbnail('post-thumbnails', $default_attr);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.