Support

Account

Home Forums Add-ons Gallery Field Alt tag with wp_get_attachment_image()

Solved

Alt tag with wp_get_attachment_image()

  • I’m trying to figure out how to get the alt tag when using wp_get_attachment_image() I’ve found this forum post and was reading the WordPress docs but I really just don’t know where to begin with the gallery output.

    I’m paginating the gallery with some earlier research, but this is my code for the gallery loop:

    foreach( $images as $image ):
        echo wp_get_attachment_image( $image['ID'], $size ); 
    endforeach;
  • Doh! The alt displays by default BUT you need to have an ALT entered on the image (I had a caption and no alt text, so the alt was not showing). I thought the markup would still be there but empty alt="" but if no alt there is not alt markup output.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Alt tag with wp_get_attachment_image()’ is closed to new replies.