Last active
February 1, 2017 12:32
-
-
Save vovadocent/9b2dfb17839085c24fdc7864baede1d6 to your computer and use it in GitHub Desktop.
Fixing Custom Post Type Archive Pagination WordPress 404
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 | |
function custom_posts_per_page($query) { | |
if ( !is_admin() && $query->is_archive() && is_post_type_archive('packages') ) { | |
$def_ppp = 4; | |
$ppp = isset($_COOKIE['ppp']) && (int) $_COOKIE['ppp'] > $def_ppp ? intval($_COOKIE['ppp']) : $def_ppp; | |
set_query_var('posts_per_page', $ppp); | |
set_query_var('city', 0); | |
set_query_var('class', 0); | |
} | |
} | |
add_action('pre_get_posts', 'custom_posts_per_page'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment