Skip to content

Instantly share code, notes, and snippets.

@corenominal
Last active January 6, 2016 19:30
Show Gist options
  • Save corenominal/01bd2fa2ff8374ebcb81 to your computer and use it in GitHub Desktop.
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.
<?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