custom post type paging not working past page 3

Don’t run custom queries in the template to modify query parameters. The main query runs before the template is loaded, doing this is a waste of resources and introduces pagination issues, as you have discovered.

Remove your custom WP_Query, restore the normal loop, and use pre_get_posts to modify query parameters before the query is run.

function wpa_services_posts_per_page( $query ) {
    if ( !is_admin()
    && $query->is_post_type_archive( 'services' )
    && $query->is_main_query() ) {
        $query->set( 'posts_per_page', 5 );
    }
}
add_action( 'pre_get_posts', 'wpa_services_posts_per_page' );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)