Pagination on template page to display CPT archives
-
Hi,
I want to use a page, with a specific template, as an archive for one post type, in this case the Portfolio post type.
In the register_post_type() arguments, I’m passing
'has_archive' => false
, and I have created a page with name portfolio (slug ‘portfolio’). Works fine, but the pagination doesn’t work so well.My permalink structure is: /%category%/%postname%
https://www.mysite.com/portfolio – I have the correct result and the template page is displayed with my custom query, everything ok.
https://www.mysite.com/portfolio/page/2 – Error 404.
If I define
'rewrite' => false
in the register_post_type function, the pagination will work, yet, the singles will have a bad url: https://www.mysite.com/?portfolio=project-1That’s all. I want to know if have some solution for this, or else, if this is a bad structure to create manageable archive pages. (the problem is the pagination, the parameter
'has_archive' => false
works great when there’s no need of pagination. I think it’s not a bad way to do it, but something is going wrong)Gist link: https://gist.github.com/allysonsouza/61c48cea9db17ed9d12a
Thanks
- The topic ‘Pagination on template page to display CPT archives’ is closed to new replies.