Support » Themes and Templates » Post_thumbnail image title as post title

  • Hello,

    I’m using the post_thumbnail function and the image that results always has the image title instead of the post’s title it belongs to. Sure, I could manually type in the post titles for the image titles when adding it as the featured image, but that’s a little too tedious.

    Is there a way to automatically set the thumbnail’s image title="..." to the post’s title?

Viewing 1 replies (of 1 total)
  • Thread Starter scferg

    (@scferg)

    I think I’ve answered part of my question. As documented here:

    $default_attr = array(
    			'src'	=> $src,
    			'class'	=> "attachment-$size",
    			'alt'	=> trim(strip_tags( $attachment->post_excerpt )),
    			'title'	=> trim(strip_tags( $attachment->post_title )),
    		);

    I’m just now unsure of where to place that snippet of code to get it to work. Or I could be off completely.

Viewing 1 replies (of 1 total)
  • The topic ‘Post_thumbnail image title as post title’ is closed to new replies.