Created
June 10, 2013 06:13
-
-
Save dlh01/5746835 to your computer and use it in GitHub Desktop.
religionnews.com uses the Zoninator plugin to control our front page story hierarchy. This function collects our 'Headlines' zone as part of the main front page query, rather than ignoring the main query and starting a new one.
This file contains hidden or 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
add_action( 'pre_get_posts', 'rns_get_headlines_zone', 10 ); | |
/** | |
* Get the posts in the 'Headlines' zone in the front page main query | |
* | |
* @param obj $query The query to pass to the database | |
* @see Zoninator's get_zone_query() | |
*/ | |
function rns_get_headlines_zone( $query ) { | |
if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) { | |
global $zoninator; | |
$query->set( 'order', 'ASC' ); | |
$query->set( 'posts_per_page', -1 ); | |
$query->set( 'post_type', $zoninator->get_supported_post_types() ); | |
$query->set( 'ignore_sticky_posts', '1' ); | |
$query->set( 'post_status', 'publish' ); | |
$query->set( 'orderby', 'meta_value_num' ); | |
$query->set( 'meta_key', $zoninator->get_zone_meta_key( 'headlines' ) ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment