Last active
May 24, 2018 16:20
-
-
Save landbryo/cc2860cc9b33e799473445938a3b3ac8 to your computer and use it in GitHub Desktop.
Shortcode for displaying a feed of blog posts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////// | |
// 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment