Example #1
0
	<?php 
while (have_posts()) {
    the_post();
    ?>

		<article id="post-<?php 
    the_ID();
    ?>
" <?php 
    post_class();
    ?>
 itemscope itemtype="http://schema.org/LocalBusiness">
			<?php 
    if (!post_password_required()) {
        $photos = listable_get_listing_gallery_ids();
        if (!empty($photos)) {
            ?>

					<div class="entry-featured-carousel">
						<?php 
            if (count($photos) == 1) {
                $myphoto = $photos[0];
                $image = wp_get_attachment_image_src($myphoto, 'listable-featured-image');
                $src = $image[0];
                ?>
							<div class="entry-cover-image" style="background-image: url(<?php 
                echo $src;
                ?>
);"></div>
						<?php 
Example #2
0
/**
 * Return the ID of the first image found in the post meta (featured image). In case of listings first we will look into the gallery (main_image) and then for the featured image
 *
 * @param null $post_ID
 *
 * @return array|bool|string
 */
function listable_get_post_image_id($post_ID = null)
{
    if (empty($post_ID)) {
        $post_ID = get_the_ID();
    }
    //get the presentation gallery if present
    $gallery_ids = listable_get_listing_gallery_ids($post_ID);
    //now lets get the image (either from the presentation gallery or the featured image
    // if there are second images, use them
    if (!empty($gallery_ids)) {
        return $gallery_ids[0];
    } else {
        // fallback to featured image
        return esc_sql(get_post_thumbnail_id($post_ID));
    }
    return false;
}
Example #3
0
    public function widget($args, $instance)
    {
        global $post;
        $photos = listable_get_listing_gallery_ids();
        if (!empty($photos)) {
            echo $args['before_widget'];
            ?>

			<header class="listing-gallery__header">
				<span class="listing-gallery__title"><?php 
            esc_html_e('Photo gallery', 'listable');
            ?>
</span>
				<a href="<?php 
            echo wp_get_attachment_url(intval($photos[0]));
            ?>
" class="listing-gallery__all"><?php 
            echo esc_html__('All photos', 'listable') . ' (' . count($photos) . ')';
            ?>
</a>
			</header>
			<div class="listing-gallery__items  js-widget-gallery">

				<?php 
            foreach ($photos as $key => $photo_ID) {
                ?>
					<a href="<?php 
                echo wp_get_attachment_url($photo_ID);
                ?>
" class="listing-gallery__item">
						<?php 
                echo wp_get_attachment_image($photo_ID, 'thumbnail', false, array('itemprop' => 'image'));
                ?>
					</a>
				<?php 
            }
            ?>

			</div><!-- .listing-gallery__items -->

		<?php 
            echo $args['after_widget'];
        }
    }