Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Last active July 14, 2016 16:03
Show Gist options
  • Save propertyhive/11b8f43455d5a91dfa2776797940947a to your computer and use it in GitHub Desktop.
Save propertyhive/11b8f43455d5a91dfa2776797940947a to your computer and use it in GitHub Desktop.
<?php
/**
* Single Property Images
*
* @author PropertyHive
* @package PropertyHive/Templates
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $post, $propertyhive, $property;
$gallery_attachments = $property->get_gallery_attachment_ids();
?>
<div class="images">
<?php
if ( !empty($gallery_attachments) )
{
$j = 0; // use this to keep track of the total images
foreach ($gallery_attachments as $gallery_attachment)
{
if ( $j > 0 )
{
echo '<div style="float:left; width:50%; padding:0 1%;">';
}
$image_title = esc_attr( get_the_title( $gallery_attachment ) );
$image_link = wp_get_attachment_url( $gallery_attachment );
$image = wp_get_attachment_image( $gallery_attachment, 'original' );
echo apply_filters( 'propertyhive_single_property_image_html', sprintf( '<a href="%s" class="propertyhive-main-image" title="%s" data-rel="prettyPhoto[ph_photos]">%s</a>', $image_link, $image_title, $image ), $post->ID );
if ( $j > 0 )
{
echo '</div>';
}
++$j;
}
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment