Created
March 26, 2013 01:25
-
-
Save tocky/5242377 to your computer and use it in GitHub Desktop.
Wordpress Media Library の画像をメタ情報とともに表示する方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Refs: http://wordpress.org/support/topic/get-title-alt-or-caption-from-media-library-and-insert-into-theme --> | |
<?php | |
$args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'numberposts' => null, 'post_parent' => $post->ID ); | |
$attachments = get_posts($args); | |
if ($attachments) { | |
foreach ( $attachments as $attachment ) { | |
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); | |
$image_title = $attachment->post_title; | |
$caption = $attachment->post_excerpt; | |
$description = $image->post_content; | |
?> | |
<div> | |
<a href="<?php echo wp_get_attachment_url( $attachment->ID); ?>" rel="lightbox" title="<?php echo $image_title; ?>"><img src="<?php echo wp_get_attachment_url( $attachment->ID , false ); ?>" alt="<?php echo $alt; ?>" width="75" height="75" border="0" /></a> | |
<span>alt: <?php $alt?></span> | |
<span>image_title: <?php echo $image_title?></span> | |
<span>caption: <?php echo $caption?></span> | |
<span>description: <?php echo $description?></span> | |
</div> | |
<?php | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment