This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Post Thumbnail Alt

  • Creator
  • #14482
    Joshua Crosby


    Is it posible to have “alt” in post thumbnails set to load post tilte instead of actual image name?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #14495
    Jason Bobich


    There’s probably a lot of theoretical ways you could do it. Here’s possibly one way:

    function my_post_thumbnail( $output, $location, $size, $link, $image = '' ) {
    	// Get current attachment title
    	$attachment_id = get_post_thumbnail_id();
    	$old_title = sprintf( 'alt="%s"', get_the_title( $attachment_id ) );
    	// Get title for post instead
    	$new_title = sprintf( 'alt="%s"', get_the_title() );
    	// Replace the new title in for the old title
    	$output = str_replace( $old_title, $new_title, $output );
    	return $output;
    add_filter( 'themeblvd_post_thumbnail', 'my_post_thumbnail', 10, 5 );
    Joshua Crosby

    Again amazing support,thank you so much for your quick response,work like a charm!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.