Featured Posts in Display Posts Shortcode

<?php
/**
* Display Posts Shortcode, Featured Posts
* Only display featured posts using [display_posts is_featured="1"]. Assumes
* you've already set up a checkbox in metabox with key of 'be_featured'.
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/featured-posts-display-posts-shortcode/
*
* @param array $args
* @param array $atts
* @return array $args
*/
function be_display_posts_featured( $args, $atts ) {
if( isset( $atts['is_featured'] ) )
$args['meta_query'] = array(
array(
'key' => 'be_featured',
'vaue' => 1
)
);
return $args;
}
add_filter( 'display_posts_shortcode_args', 'be_display_posts_featured', 10, 2 );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk