Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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

function remove_img_title($atts) {
    unset($atts['title']);
    return $atts;
}
add_filter('wp_get_attachment_image_attributes','remove_img_title');

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);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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