I know that it’s impossible to have the same custom post type slug as a page.
So, I thought it might be resolved in this way:
'rewrite' => array('slug' => 'my-category/!#')
for register_post_type
But I get “Page not found” every time I visit /my-category/!#/title-1
As you understand, I also have a page named “/my-category”.
Is it somehow possible to resolve this conflict?
It is not impossible, but you need to be very careful to prevent conflicts. You can use my Rewrite analyzer plugin to look at your current rules.
The structure you propose, where the custom post type is stored in the URL hash (the part after the
#
), will not work because this part is not sent to the server. So the server will just see a request formy-category/!
, not formy-category/!#/my-post
. (Is it possible you switched the#
and the!
? The custom is to use#!/
as the hash start.)How to solve this depends on whether you currently have verbose page rules, and this depends on your current permalink structure. Can you edit your question to add this?
What’s happening is that the backend thinks that
!#/title-1
is a child/next page ofmy-category
. I’ve been looking at something like this today, and it just causes conflict.I found a plugin called Custom Post Permalinks which does what I want. The only thing is is that it appears to reset itself if you add a new Custom Post Type. I’m not sure how it’ll handle with your hashbang
#!/
.