Created
July 24, 2013 03:22
-
-
Save seafarer/6067849 to your computer and use it in GitHub Desktop.
Access wordpress post images uploaded and inserted through gallery function
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 | |
| $args = array( | |
| 'numberposts' => -1, // Using -1 loads all posts | |
| 'orderby' => 'menu_order', // This ensures images are in the order set in the page media manager | |
| 'order'=> 'ASC', | |
| 'post_mime_type' => 'image', // Make sure it doesn't pull other resources, like videos | |
| 'post_parent' => $post->ID, // Important part - ensures the associated images are loaded | |
| 'post_status' => null, | |
| 'post_type' => 'attachment' | |
| ); | |
| $images = get_children( $args ); | |
| if($images){ ?> | |
| <div id="slider"> | |
| <?php foreach($images as $image){ ?> | |
| <img src="<?php echo $image->guid; ?>" alt="<?php echo $image->post_title; ?>" title="<?php echo $image->post_title; ?>" /> | |
| <?php } ?> | |
| </div> | |
| <?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment