Forums

Simple Alt Value for Custom Field (1 post)

  1. Pan Fried Pixels
    Member
    Posted 5 months ago #

    Hi there,

    So I'm running a loop on a series of custom fields to populate a simple slideshow feature. This is all working fine but the problem I have is that I cannot figure out how to attribute the alt text I have defined when initially uploading images to the media library.

    Here's the code:

    <?php $businessimagemain = get_post_meta($post->ID, 'Business image main', false); ?>
    
      <?php if ( $businessimagemain ) : ?>
        <?php foreach($businessimagemain as $businessimagesmain) {
          $alt_text = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
          echo '<img src="'.$businessimagesmain.'" alt="'.$alt_text.'" />';
        } ?>
    
      <?php else : ?>
        <p>Slideshow currently unavailble.</p>		      
    
      <?php endif; ?>

    Any ideas guys?

    Cheers

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 5 months ago by Pan Fried Pixels
  • This topic is not resolved
  • WordPress version: 3.2.1