Skip to content

Instantly share code, notes, and snippets.

@mattyza
Created February 11, 2013 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyza/a5e2da828b2e6694bd53 to your computer and use it in GitHub Desktop.
Save mattyza/a5e2da828b2e6694bd53 to your computer and use it in GitHub Desktop.
Adjusts homepage query if the "Magazine" template is used as the homepage.
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