Shortcode for displaying a feed of blog posts.
//////////////////////////////
// BLOG LIST FEED SHORTCODE //
//////////////////////////////
add_shortcode( 'bw_blog_list', 'blog_list_shortcode' );
function blog_list_shortcode( $atts ) {
ob_start();
$kblog_args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
);
$kblog_posts = new WP_Query($kblog_args);
if ( $kblog_posts->have_posts() ) { ?>
<div class="keokee-blog-list">
<?php while ( $kblog_posts->have_posts() ) : $kblog_posts->the_post(); ?>
<div class="keokee_one_third column-top-margin">
<h3>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h3>
<p><?php the_excerpt(); ?></p>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
</div>
<?php $keokee_blog_list = ob_get_clean();
return $keokee_blog_list;
}
}