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 have a theme that uses TimThumb to generate thumbnail images on a gallery page. The problem is that image alt tags are not showing for each image on the main gallery pages, see here:

http://christinecraven.com/gallery/press

I've tried to generate the alt tag by adding a custom field in each post/ portfolio item, called "alt_tag" and then calling it in the category.php file in my theme:

$alttag = get_post_meta($post->ID, 'alt_tag', true);

<div class="imgHentry">
    <?php the_post_thumbnail( 'thumbnail' ); ?> alt="<?php echo get_post_meta($att, 'alt_tag', true); ?>" 
    <div class="linkIcon" style="width:150px; height:150px;">
        <a href="<?php the_permalink(); ?>" class="goto-icon" style="width:150px; height:150px;"></a>
    </div>
</div><!-- .imgHentry -->

I found on this forum a similar question: alt attributes not showing on pages

But unfortunately can't seem to cobble together a solution that works!

share|improve this question
    
Where do you define $att? Also, the alt attribute needs to reside within the img tag, currently you are adding it outside of it. And the anchor is empty as well. –  Johannes Pille Nov 28 '12 at 18:30
add comment

1 Answer 1

The following ought to be much closer to what you want to achieve:

<div class="imgHentry">
    <a href="<?php the_permalink(); ?>" class="goto-icon">
        <?php the_post_thumbnail(
            'thumbnail',
            array( 'alt' => get_post_meta( $post->ID, 'alt_tag', true ) )
       ); ?>
    </a>
</div>
share|improve this answer
    
Sadly, it's not working. Shouldn't it be changing something though? I noticed in my original post, that yes I had made a typo in defining the $att, then tried to fix that, but that didn't seem to do anything. I wonder if I am in the correct template, but I can't imagine this isn't it. Any other ideas? Thank you! –  user24198 Nov 28 '12 at 19:11
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.