Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 –  MikeSchinkel Aug 30 '10 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. –  Adam Dempsey Aug 31 '10 at 11:18
add comment

4 Answers

up vote 3 down vote accepted

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:

share|improve this answer
    
@hakre - I added ticket #12935, and fixed your wordpress changing it to WordPress... –  MikeSchinkel Aug 30 '10 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 Aug 30 '10 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. –  MikeSchinkel Aug 31 '10 at 8:56
    
If you have an opinion on this matter, please join the discussion on the meta site! –  Jan Fabry Aug 31 '10 at 12:27
add comment

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.

share|improve this answer
    
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 Aug 30 '10 at 23:26
add comment

Hi @Adam:

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.

share|improve this answer
add comment

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?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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