Skip Navigation

[Resolved] Custom URL Rewrite stops pagination from working in Template pages

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 6 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#1190959
Screen Shot 2019-01-25 at 11.55.55.png

Hi,

I have a CPT 'Projects' that I am loading into a grid in a page 'Work'. The pagination only works if I use the normal WordPress URL logic. If I set it to 'work' instead, the pagination stops working and I get the theme's 404 page.

#1191031

I believe you should not name Post Types, or URL rewrites, or Pages, the exact same slug as an existing Post or Type or URL rewrite.
This will result in conflicts, even on a native WordPress install without Toolset.

You can test this like follows:

1. Create a Custom Post Type with hidden link and make sure to permalink it with a slug of an existing page.
2. Load this CPT on your website, and repeat what you tried with the Toolset Post Type
3. The same issue should happen, according to my tests.

On your site, the Projects CPT right now is using default permalinks (post name) so I cannot see the issue, and also I am not clear how the posts are brought to that page, as no View seems to display them(?).

However, given that having the same slugs of post types (or rewrites) will result in any of the involved returning a 404, I would suggest renaming the page to something else.

#1191072

Thanks for explaining. The site is custom built using php. I didn't use Views. I wanted to name the CPT the same as the page so that the URLs don't change. If I'm on the 'Work' page and I clicked on a project, I expect the url to be /work/project-name.

I'm guessing that this isn't possible. That's a shame.

#1191394

Correct, this issue does as well happen when you use a manually coded Custom Post Type following the WordPress coding standards and rewrite that to a page's slug or vs, later create a page using the type's or rewrite's slug.

A quick search for this problem shows it is a widely reported issue in WordPress, not Toolset (Toolset is "affected" because it lets you create Post Types).
For example, see this StackOverflow article and others:
https://stackoverflow.com/questions/47982083/wordpress-page-and-custom-post-type-with-this-same-slug
hidden link
https://wordpress.stackexchange.com/questions/135146/resolve-a-custom-post-type-name-vs-page-permalink-conflict-same-slug
Note that the symptoms are always slightly different, but it is always "breaking" the setup.
https://wordpress.org/ideas/topic/allow-custom-post-types-to-have-noempty-slug-or-appear-as-top-level-permalinks#post-28895
There are also (very old) "bug" reports on the Core of WordPress, that are closely related (but not the exact same) to this experience:
https://core.trac.wordpress.org/ticket/13459 (and related)

Unfortunately, having the exact same precise slug in both is something that is not possible within the core.

This is the same if you were to create the Post Type with Toolset Types, as it uses the WordPress standards to register them.