Example #1
0
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        echo $before_widget;
        $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        // WIDGET CODE GOES HERE
        $OneImageQuery = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 1, 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-image')))));
        // The Loop
        if ($OneImageQuery->have_posts()) {
            while ($OneImageQuery->have_posts()) {
                $OneImageQuery->the_post();
                if (has_post_thumbnail()) {
                    echo '
					<div class="one-recent-image-wrap">
						<a href="#one-share-popup" class="one-share-image">';
                    the_post_thumbnail('quote-widget-square');
                    echo '<span class="one-share-trigger">Share This</span></a>
					</div>
					';
                    echo '
					<div id="one-share-popup" style="display: none;">';
                    the_post_thumbnail('quote-widget-square');
                    one_sharing_all();
                    '</div>';
                }
            }
        } else {
            // no posts found
        }
        /* Restore original Post Data */
        wp_reset_postdata();
        echo $after_widget;
    }
Example #2
0
    ?>
</div>
		<?php 
}
?>
	</div>
	<?php 
if (has_post_thumbnail()) {
    ?>
	<div class="post-image">
		<?php 
    the_post_thumbnail('large');
    ?>
	</div>
	<div class="post-image-content">
		<?php 
    the_content();
    ?>
	</div>
	<?php 
} else {
    ?>
		<p>This post needs a featured image.</p>
	<?php 
}
?>
	<?php 
one_sharing_all();
?>

</article>