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 have moved into WordPress for a few days and was quite impressed by all the available features, plugins and polished themes. I have spent quite some times reading documentation about themes and custom types. So far so good... Now that I'm trying to do real things, it seems (but I maybe missing something) that WP has some sever limitations.

I want to come up with a classical ISV site. A typical hierarchy would be:

  • Products
  • -- Product A
  • ---- Overview
  • ---- Release History
  • ------- Release 1.5
  • ------- Release 1.4
  • ------- Release 1.3
  • ------- etc.
  • ---- Features
  • ---- etc.
  • -- Product B
  • ---- Overview
  • List item
  • etc...

Focusing on Release History, I came up with:

  • a custom content type: "releases".
  • a custom taxonomy to specify the product associated with a specific "release".
  • I created a template to display the list of "releases".
  • Created a single-release.php to display the detail of a release.
  • Created a page based on my template.

The page URL that display the list of "releases" will basically fit into the hierarchy (/products/product-a/release-history/). However the URL of the custom post type will be something like: /%post_type%/%post_slug%/ (ie: /releases/version 1.2/

I'm struggling for 2 days trying to find a solution for coming with a coherent URL scheme.

I have tried to use to use Custom post permalinks plugin to come up with an URL that would include my custom taxonomy representing the product (better than nothing even if it's not perfect) but for some reason the plugin doesn't work on my side.

Overall, unless I'm missing something, Custom Post Types sound great but are quite a nightmare if you don't have a flat structure. I would certainly have preferred a concept of custom content type that is not URL dependant or an easy way to plug a custom post type at any level in the page hierarchy.

That said, I may be completely missing the point. Does anybody have any idea, experience when setting up a site with this kind of hierarchy? Any help appreciated...

[Update]

Not completely sure what are the conventions when updating here but I will leave the initial text for clarity purposes. The purpose of this update is to clarify and add further details.

Products
Created a WP page 'Products' - no parent - URL: http:///products/

Product A (specific product)
Created a WP page 'Product A' - parent: 'Products' - URL: http:///products/product-a/

Overview
Created a WP page 'Overview' - parent: 'Product A' - URL: http:///products/product-a/overview/

Releases (list of release for the specific product )
Created a WP page 'What's New' - applied a template that displays a list of all available releases (each release has a link to display the detail of that specific release) - parent: 'Product A' - URL: http:///products/product-a/product-releases/.
Releases are implemented using a custom type (see below). It was therefore quite easy to implement the template and link to release permalink. Though I haven't implemented it yet, my idea was that the template would display the release list for any product based on a taxonomy (product-id) defined at the page level. I could therefore have another page using the same template that would display the releases for another product by having the proper 'product-id' taxonomy attached to this other page.

Release (detail of a release)
Releases are implemented using a Custom Post Type (let's call it 'product-release'). In addition, I'm using a custom Taxonomy (product-id) to attach each release to a specific product (obviously, I don't want to create another Custom Post Type for the releases related to another product).
Created a 'single-product-release.php' file to display a specific release. The problem with this approach is that a specific release will be displayed with the following URL: http://<root>/product-releases/release-xx

  • It's not really descriptive, the least we can say (I should at least get some product identifier in the url)
  • it somewhat breaks the hierarchy (though one could certainly argue regarding if it's wrong or not)

My Options (as far as I can see as a WordPress newbie)

Get rid of the permalink stuff
Maybe I could display the detail of a release using some template and passing some argument in the URL. I could use this template with a page that would go exactly where I want in the hierarchy.
Obviously not an approach I would follow ... for many reasons I won't detail here (that's already a long post/question).

Find a way to append (or rather prefix) my 'product-id' value to the Custom Post Type permalink
We could have something like http:///product-a/product-releases/release-x. I would have to accept that releases live somewhat outside of the 'natural' hierarchy which would be http:///products/product-a/product-releases/release-x.
I could go even further by prefixing with 'products' - something like /products/%product-id%/%product-release%/. However, I'm wondering if this Rewrite Rule would not clash with the 'pages' created under the 'products' page...

Any input appreciated.

[Update]

I implemented the approach proposed by bobdiaes. This works fine for my content type however this will clash with the WP pages that are mixed in the hierarchy. Using bobdiaes piece of code, I came up with the following Permaling for my product-release custom post type:
/products/%product-id%/product-releases/%product-release%
I will therefore have the proper product URL for displaying the detail of a release for a specific product. ie: /products/my-great-product/product-releases/release-1-5/

However, I want to have some WP pages in the mix:

  • /products/my-great-product/should provide an overview of the product.
  • /products/my-great-product/product-releases/should display the list of releases + the details of the latest release.

At first, it sounds quite natural to create WP pages to do what I need. I will organize my page hierarchy so that the pages fit in the exact URL scheme. However, this approach will clash with the URL rewriting used for the "product-release" Custom Content Type and I won't be able to browse the pages (404).

Well, well, well...

So what are my options now

Give up the idea of using WP
Well, I think I'm going to insist some more. Beside this problem, there are many things to like with WP.

Use Pod CMS
Though I haven't tested it yet. It sounds like a nice framework/tool. However, I would loose the ability to easily translate my content using WPML.
The fact that they will be able to use custom post types rather than their own table in version 2.0 will certainly let them rely on current plugins for translation purposes. What they are preparing for version 2.0 sounds interesting. They will be able to use Custom Post Type instead of their own tables.
Pod CMS 2.0 could be THE SOLUTION.

Using WP pages instead of a 'product-release" Custom Post Type
The idea here would be to create a page for each product release (with product-releases page as the parent). I suppose it must be easy to loop through child pages for displaying the list of releases.
Obviously, it has quite some drawbacks:

  • The current admin page interface may not be very practical to handle hundreds of pages...
  • Because the page is already a specialized Custom Post Type (as far as I understand), I would have to remember the specific custom fields I need each time I use a page like a pseudo-content type unless I want to create all fields that may be needed all over the web site. Quite an horrible solution if you ask me.

Replace WP pages by some Custom Post Type
Not sure about the possible rewrite rules clash but here is the idea. Instead of having an overview page, I could come up with a 'product-overview' Custom Post Type and use a permalink rewriting rule the same way I did for 'product-release' Custom Post Type. Will update with my findings.

I'm sure I'm not the only facing this WordPress URL hell. Though I have to admit that the Generalisation of a "post" into a custom post type is quite clever, the permalink stuff comes with its own constraints.

A word of caution - being new with WP, I may have overlooked something completely obvious

[Update]

Well, as frustrating as it may be, it seems that this is just impossible. Well there is certainly a solution that involves some tricky URL rewriting but certainly nothing trivial for an approach that is however quite common.
Basically, I believe at this stage, that one should tie to a rather simple URL scheme. Will try the wordpress forum, but I don't have much hope.

share|improve this question
    
@Frederic L: In trying to answer your question it occurs to me you don't have enough data defined for your desired URL structure; you need a 'product' Custom Post Type too. And I would definitely not name a Custom Post Type as plural of a Custom Taxonomy. I'm going to suggest you name the Custom Post Type 'release' (singular) and your Custom Taxonomy as 'version' (also singular). And to minimize conflicts with future additions of WordPress I'll recommend you prefix them with 'product', i.e. 'product-release' and 'product-version'. Will that work for you? –  MikeSchinkel Oct 13 '10 at 5:27
    
Your naming recommendations make sense - that would have been my first approach (like an entity). However, I had just followed Custom Post Type UI recommendations (sample within parenthesis) and thought I should certainly follow theses guidelines so as not to make things more difficult later. I can't really see how having a 'product' Custom Post Type would help in having a coherent naming scheme. Is there a way to link hierarchically 2 Custom Post Types? Not sure about your 'version' taxonomy suggestion. Is that mean to differentiate my various products? Maybe I will update my initial post. –  Frederic L Oct 13 '10 at 17:01
add comment

2 Answers

When planning more complex Wordpress sites, I try to think of the page/url hierarchy in terms of the default WordPress Database Schema. Then determine the best URL rewrite scheme and data structure. Very generally, I find that data objects most important to the user should exist as a custom post type or a post object, relationships between custom posts should use custom taxonomies and unique values should be stored in postmeta.

More specifically, if I was offering products with version updates, I might create a custom post type for each product (assuming a limited number of total products with version updates) and create a new post for each new release (WP stores posts chronologically by default, so multiple releases should work well). In other words, each new release would exist as a single post under the custom post type and each new post will contain the details of that release. You could then display the details for the most recent post on a page for the custom post type. By forcing each post to be paginated, you should also be able to have separate URL's for features, etc., and you should be able to make them pretty by rewriting the URL.

Visually:

/products/%custom-post-type%/
/products/product-a/

/products/%custom-post-type%/archive/
/products/product-a/releases/

/products/%custom-post-type%/%post-name%/
/products/product-a/release-xx/

/products/%custom-post-type%/%post-name%/page/2/
/products/product-a/release-xx/features/
share|improve this answer
add comment

I think you need to hook on the get_permalink() function. This article I've saved in my custom post type notes might be of help: http://shibashake.com/wordpress-theme/add-custom-taxonomy-tags-to-your-wordpress-permalinks

share|improve this answer
    
Not sure what's going wrong but when trying your code, I just get a blank page whatever the URL of my site. Could it be that my custom taxonomy has been created using a plugin? –  Frederic L Oct 13 '10 at 16:34
    
It looks like there is a typo in the code that is displayed on your page: add_filter('post_type_link', 'rating_permalink' ) , 10, 3); After removing the parenthesis, I got it to work. I'm going to investigate deeper this approach and see if it can make things work. –  Frederic L Oct 13 '10 at 22:54
    
Your approach works fine with Custom Post Types. However, if I want to put some pages in the mix, it will clash with the rewrite rules. I will update the question to describe this in more details... –  Frederic L Oct 14 '10 at 12:01
    
You probably want to use another custom type for product overviews. Also check out the Posts2Posts plugin, which lets you define many-to-many relationships between posts of any type. Sidenote: I didn't come up with that approach, just had that article bookmarked. –  bobdiaes Oct 14 '10 at 15:28
    
However there is still a problem because, unless I'm missing something, I still need a WP page (with an associated template) for the landing page that will list the custom posts. Therefore, as far as I see it, my problem will still stand. Maybe I should have a look at the showcase section and see if I can find a site that has similar requirements and have a look at the URLs. –  Frederic L Oct 14 '10 at 16:13
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.