Created
January 29, 2014 20:12
-
-
Save RevConcept/8695999 to your computer and use it in GitHub Desktop.
WordPress: Display All Post Attachment Images In A Slider. Original post here: http://revelationconcept.com/wordpress-display-all-post-attachment-images-in-a-slider
This file contains 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
// This is modified to show the image captions | |
function revconcept_get_images($post_id) { | |
global $post; | |
$thumbnail_ID = get_post_thumbnail_id(); | |
$images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ); | |
if ($images) : | |
foreach ($images as $attachment_id => $image) : | |
if ( $image->ID != $thumbnail_ID ) : | |
$img_cap = $image->post_excerpt; // New line to get the caption | |
$img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); //alt | |
if ($img_alt == '') : $img_alt = $image->post_title; endif; | |
$big_array = image_downsize( $image->ID, 'large' ); | |
$img_url = $big_array[0]; | |
echo '<li>'; | |
echo '<img src="'; | |
echo $img_url; | |
echo '" alt="'; | |
echo $img_alt; | |
echo '" />'; | |
echo $img_cap; // New line to show the caption under the photo | |
echo '</li><!--end slide-->'; | |
endif; endforeach; endif; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment