<?php
function latest_blog( $atts )
{
ob_start();
$args = array(
'post__not_in'=>array($array),
'post_type' => 'post',
'posts_per_page' => 3,
);
echo '<div class="blog-post-wrapper">';
$the_query = new WP_Query($args);
if($the_query->have_posts()):
while ($the_query->have_posts()) : $the_query->the_post();
$post_date = get_the_date('jS F Y');
$post_link = get_the_permalink();
?>
<div class="blog-post-box">
<div class="post-img">
<a href="<?php echo $post_link; ?>">
<figure>
<?php the_post_thumbnail('post-thumbnail');?>
</figure>
</a>
</div>
<div class="post-body">
<p><?php echo $post_date; ?></p>
<a href="<?php echo $post_link; ?>"><h2><?php echo get_the_title(); ?></h2></a>
<p><?php echo get_the_excerpt(); ?></p>
<a href="<?php echo $post_link; ?>">Read More</a>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
echo '</div>';
return ob_get_clean();
}
add_shortcode( 'latest_blog', 'latest_blog' );
?>