Get Title, Alt, or Caption from Media Library and insert into theme
-
I have researched several blog posts for the last couple hours and just can’t figure out how to solve my issue. I have the following code that inserts all the thumbnail images from a media gallery in my media library:
<?php $args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ( $attachments as $attachment ) { ?> <a href="<?php echo wp_get_attachment_url( $attachment->ID , false ); ?>" rel="lightbox" title="<?php the_title_attribute(); ?>"><img src="<?php bloginfo('template_url'); ?>/timthumb.php?h=75&w=75&zc=1&src=<?php echo wp_get_attachment_url( $attachment->ID , false ); ?>" alt="" width="75" height="75" border="0" /></a> <?php } } ?>
Currently I’m just using “the_title_attribute();” which just grabs the post title for the image title. How can I grab the actual title, alt, or caption from the media library instead?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Get Title, Alt, or Caption from Media Library and insert into theme’ is closed to new replies.