I currently have this:
mysite.com/product-name
mysite.com/another-product
etc where product-name and another-product are posts.
I then have a custom post type called Changelogs, which I have for each product, is it possible to have the url something like:
mysite.com/product-name/changelog
mysite.com/another-product/changelog
If so, how would I go about doing it?
There is no such thing as “Sub Posts” in WordPress already built in.
But it could be possible that you create a plugin that is introducing “Sub Posts” in the style you describe them.
Technically you’re not talking about subposts but about the URL-Layout. So in WordPress you add an endpoint (“changelog”) that you can handle with some plugin, for example switching display to some other post.
Once this did not properly work with endpoints but I think it’s somehow fixed now. Haven’t used it tough, so my answer is only informative so far.
Related:
After completing the answer above it occurs to me that you might be able to achieve what you want more simply that I was first thinking by leveraging the answer a wrote in this question:
I know the question title would not imply to you that it would be relevant but the question was in essence about “sub post” type of information and related URLs.
Sorry it didn’t occur to me until after I posted the answer above.
Hi @Adam:
As you probably know all “posts” are stored in the same database table for “Posts”, “Pages” and any Custom Post Types.
I mention the previous to emphasize that all “posts” have the field
post_parent
available and I have used it successfully to create a parent-child relationship between, for example, a'restaurant'
post type and a'restaurant-location'
post type.The URLs are a good bit trickier, however, and I’m a fanatic when it comes to Well Designed URLs so you’d know I would look into is heavily.
I have implemented the code to do similar to what you ask for (for the restaurant/location example) but it is extremely fragile and has the potential to create unwanted side effects with other plugins so I’d really fear posting it here and in effect causing people more trouble than help.
While some of the more hardcore WordPress devs that frequently trac and the wp-hackers list don’t seem to think there’s much of an issue with the URL routing system everyone else I know who has actually tried to use it for any other pattern besides blogging struggles with it and finds it infuriating. That’s why I submitted this ticket and hope to have some dedicated time to address in the near future:
Currently using Well Designed URLs is just too damn hard and fraught with peril to be a viable option. So in the short term I really recommend going with the standard URL layout until I get enough free time to tackle it, or someone else improves WordPress’s URL routing system or someone even hires me to fix it.
Unfortunately I know it wasn’t the answer you were looking for but it is an honest and heartfelt one.
I’ve come back to this project after not working on it for a while and this is what I’ve got:
so as with my previous examples where I have:
mysite.com/product-name/changelog
mysite.com/another-product/changelog
those are posts (of type changelog) and the actual slug is product-name-changelog
I then use the Redirection plugin to do a pass through from
to
But it ends up redirecting as a 301 to mysite.com/product-name-changelog
I’ve tried hooking to wp_redirect and canonical_redirect so I could try stop the redirect but without any luck so far.
Any suggestions on what else to try?