Created
February 18, 2013 23:26
-
-
Save lschatzkin/4981703 to your computer and use it in GitHub Desktop.
Custom gallery call for custom templates
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
function tl_create_gallery () | |
{ | |
$postID = get_the_ID(); | |
$args = array( | |
'numberposts' => -1, | |
'order'=> 'ASC', | |
'post_mime_type' => 'image', | |
'post_parent' => $postID, | |
'post_status' => null, | |
'post_type' => 'attachment' | |
); | |
$images = get_children( $args ); | |
echo '<div class="single-property-gallery">'; | |
if ($images) { | |
foreach($images as $image) { | |
$image_attributes = wp_get_attachment_image_src( $image->ID, 'property-thumb' ) ? wp_get_attachment_image_src( $image->ID, 'property-thumb' ) : wp_get_attachment_image_src( $image->ID, 'full' ); | |
$full_url = wp_get_attachment_image_src( $image->ID, 'full'); | |
echo '<a href="' .$full_url[0]. '"><img src="'. $image_attributes[0] . '" width="'.$image_attributes[1].'" height="'. $image_attributes[2].'" class="property-thumb"></a>'; | |
} | |
} | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment