1

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?

2
  • As an aside any reason you are not using Custom Post Type for Products? It would make a huge amount of sense to set products up using Custom Post Types; this answer from today can even tell you how to change them: wordpress.stackexchange.com/questions/1037 Commented Aug 30, 2010 at 19:28
  • I will be switching the posts over to a custom post type soon, I've only recently switched the changelogs from posts to a custom post type. Commented Aug 31, 2010 at 11:18

4 Answers 4

3

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:

4
  • @hakre - I added ticket #12935, and fixed your wordpress changing it to WordPress... Commented Aug 30, 2010 at 19:03
  • @MikeSchinkel: Please don't mess with the casing of my words. That's especially for Wordpress. I'm preferring the orthographically correct english for writing names in the end, but all lowercase is my style as well. I know that others have other styles, but please don't make me care by changing that in my writing. Thanks.
    – hakre
    Commented Aug 30, 2010 at 20:26
  • This should be a community resource. This shouldn't be about one person's style or another. We've discussed on meta consistency but not at length. To say it bluntly all lowercase comes across as juvenile. Since you are very active on the site you are generating a lot of content and your style will create an impression. I'm going to ask explicitly on meta if others think we should edit for consistency or leave everyone to their own devices. I strongly think we should but if everyone else disagrees I'll let it go. OTOH, if they agree then I'll keep editing and ask you to improve. Commented Aug 31, 2010 at 8:56
  • If you have an opinion on this matter, please join the discussion on the meta site!
    – Jan Fabry
    Commented Aug 31, 2010 at 12:27
0

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.

0

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.

1
  • I always said, that it's missing a lot and I wish you all the best with that ticket. Really. I know what you're talking about and the URL management / routing configuration in WP big time, well, you know.
    – hakre
    Commented Aug 30, 2010 at 23:26
0

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

​/([a-zA-Z0-9-]*)​/changelog​/$

to

/$1-changelog/

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.