Finding the answer to common WordPress issues can be a headache sometime, so we like to post little gems here to help someone in the future.

We recently had an issue setting up a Custom Post Type Pagination. The first page was all working fine as expected, but when trying to access page 2, page 3, page 4 (anything above 1) we received an Error 404 accessing the page.

A lot of posts suggested setting the ‘post_per_page’ variable and updating the functions file. However, we had the posts per page working as we expected… If you do need to change the posts per page for a custom post type here is how anyway:

$args = array( 
        'post_type' => 'client-reviews',
        'orderby' => 'date',
        'order'   => 'DESC',
        'posts_per_page' => 3,
        'paged' => get_query_var('paged')
    $review_query = new WP_Query( $args );

You can also do this in the functions file if needed:

function my_custom_posts_per_page( $query ) {
if (!is_admin() && post_type_exists('client-reviews') )
        $query->set( 'posts_per_page', 3 );
add_filter('parse_query', 'my_custom_posts_per_page');

Back to the topic… As mentioned these did not resolve or point us to the correct solution. We did stumble across this which helped:

This explains that you cannot have a PAGE and a CUSTOM POST TYPE with the same name. For example, if your page is called ‘reviews’ and your custom post type slug is ‘reviews’ they will collide!

Once we changed the page name everything was working as expected and the pagination, page 2, page 3 etc. all worked as expected again.

© 2017 Morris Projects Ltd. Paschal Way, Chelmsford, Essex, CM27NX. 01245 206566. Company Reg: 06837962

Our Friends: Chelmsford Web Design, Chelmsford Music Studio.