Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

jeriksson on "Get post title as the_post_thumbnail alt tag, how?"

$
0
0

Hi,

I'm a novice at this, i can't figure out how to get the post title as the post_thumbnail alt tag, i've read a couple of threads and tried using this code but it won't work, i'm suspecting i've missed something or formated the code incorrectly, can someone take a look at it?

<div class="entry-summary">
		<div class="excerpt-thumb">
			<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?>
			<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'gopiplustheme' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
				<?php  the_post_thumbnail( array( 'alt' => trim( strip_tags( $attachment->post_title()));
			</a>
			<?php endif;?>
		</div>

original theme code looks like this:

<div class="excerpt-thumb">
			<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?>
			<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'gopiplustheme' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
				<?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?>
			</a>
			<?php endif;?>
		</div>

thank you!


Viewing all articles
Browse latest Browse all 8245

Trending Articles