Created
February 8, 2014 11:38
-
-
Save illucent/8882450 to your computer and use it in GitHub Desktop.
all images for a slider / http://revelationconcept.com/wordpress-display-all-post-attachment-images-in-a-slider/
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
| <?php | |
| 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_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 '</li><!--end slide-->'; | |
| endif; endforeach; endif; } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://rudrastyh.com/wordpress/slider-in-posts.html