Our web site is using the theme's slider.php on our front page. I'd like for the images displayed in that slider to use the alt text that is in the post meta (edited in the WP media library).
I've attempted to create a variable ($alt), and have that variable echoed when the img is called, but is coming up empty. Here's the relevant portion of slider.php:
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
<img src="<?php echo $thumbnail[0]; ?>" alt="<?php echo $alt[0]; ?>" />
</a>
<?php else: ?>
` Any idea what I'm doing wrong?
You have set the third argument as
true
which means the functionget_post_meta
returns a string;http://codex.wordpress.org/Function_Reference/get_post_meta
Therefore the following should work instead;