Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Adjusts homepage query if the "Magazine" template is used as the homepage.

View magazine-template-query-adjustment.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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
Something went wrong with that request. Please try again.