Created
February 11, 2013 07:51
-
-
Save mattyza/a5e2da828b2e6694bd53 to your computer and use it in GitHub Desktop.
Adjusts homepage query if the "Magazine" template is used as the homepage.
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
if ( ! function_exists( 'woo_modify_magazine_homepage_query' ) ) { | |
function woo_modify_magazine_homepage_query ( $q ) { | |
if ( ! is_admin() && $q->is_main_query() && ( 0 < $q->query_vars['page_id'] ) && ( $q->query_vars['page_id'] == get_option( 'page_on_front' ) ) && ( 'template-magazine.php' == get_post_meta( intval( $q->query_vars['page_id'] ), '_wp_page_template', true ) ) ) { | |
$settings = woo_get_dynamic_values( array( 'magazine_limit' => get_option( 'posts_per_page' ) ) ); | |
$q->set( 'posts_per_page', intval( $settings['magazine_limit'] ) ); | |
$q->set( 'paged', intval( $q->query_vars['page'] ) ); | |
$q->parse_query(); | |
} | |
return $q; | |
} // End woo_modify_magazine_homepage_query() | |
} | |
add_filter( 'pre_get_posts', 'woo_modify_magazine_homepage_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment