Category Archives: hack

Pagination for Custom Post Types

Getting pagination for your custom post type indexes isn’t too hard.

Set the variable $paged:


$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

Be sure that ‘paged’ is in your args for your WP_Query:


'paged' => $paged,

Output the links:


$output .= paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query_name->max_num_pages
) );