Last active
January 6, 2016 19:30
-
-
Save corenominal/01bd2fa2ff8374ebcb81 to your computer and use it in GitHub Desktop.
A WordPress function to fix pagination when combining custom post types in a single loop.
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
<?php | |
/** | |
* WordPress function to fix pagination when combining custom post types in a single loop. | |
*/ | |
function fix_allcustomposts_pagination($qs) | |
{ | |
if( !isset( $qs['post_type'] ) && isset($qs['paged']) ) | |
{ | |
$qs['post_type'] = get_post_types($args = array( | |
'public' => true, | |
'_builtin' => false | |
)); | |
array_push($qs['post_type'],'post'); | |
} | |
return $qs; | |
} | |
add_filter('request', 'fix_allcustomposts_pagination'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment