-
-
Save billerickson/44db3a4a1a1fe1c52e32ee2752c06d77 to your computer and use it in GitHub Desktop.
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
<?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' => 'on', | |
) | |
); | |
return $args; | |
} | |
add_filter( 'display_posts_shortcode_args', 'be_display_posts_featured', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment