Pagination of custom post types inside custom post type’s “single” template

A while ago, I was asked to take over a small project involving solving quite a few problems with a custom WP theme. I managed to solve most of the issues, but one of them I cannot get my head around. Here is the situation.
We have a custom post type (let’s call it P1) and in the single-P1.php file we have a WP_query that gets all posts of another type (call that P2) with pagination.

However, the pagination does not work. If we click on any page number, we get back to the original post page (P1) with the first 10 results of P2.

Read More

We use the $paged variable, but looks like it does not work. The URL the pagination is pointing us ( /page/2/ ) gives me a 301 redirect error.

I re-saved the permalink structure after reverting to default, but still nothing…

Can anyone help me with this?

Thanks!

Related posts