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 am currently new to Wordpress development and I am developing a custom theme with a few custom post types and custom functionality. For the most part, it was pretty easy to find the information I need on the Internet and the codex. I am importing an older outdated system (proprietary) into Wordpress and I would like to be able to keep all the sub-pages of this older system in Wordpress to take advantage of some powerful features and plugins. I have almost everything complete but I am a little confused on how to produce a hierarchical order for custom post types.

I have Wordpress installed in a sub folder (wordpress) from the domain root. I have a front-page setup to show the themes front page which aggregates data from other systems. I was able to use add_rewrite_rule to get some pages working properly with clean URIs.

My problem is: I have a few systems that are auto generated from a separate database. For simplicity I will call these systems services.

I currently have 2 services and there will eventually be more. The issue I am having is that each service will need to have it's own page with it's own sub-pages.

i.e.: (main page): domain.com/services/aims domain.com/services/rcm

(sub-pages): domain.com/services/aims/list domain.com/services/aims/profile

domain.com/services/rcm/list domain.com/services/rcm/profile

Each system will be built using the same functionality. The list page will list vendors for each service while the profile page will show detailed information for each vendor.

I also want to be able to post articles in each system as well.

ie: domain.com/services/aims/articles/?(.+)? domain.com/services/rcm/articles/?(.+)?

My question is this: Is this functionality possible in Wordpress? I tried using custom post types to get the URI to work but I was not sure of how to implement the articles. I know I can use query_vars to show different page content and this will emulate what I am trying to do with list and profile but I cannot figure out how to allow for articles to be posted to each service. I would like to use the same files for the services instead of having to make new files every time a service is added.

The desired effect I am going for is that each service has the ability to post content to itself to keep it organized, list vendors in a list page, and show the vendor details. I know I will need to have custom navigation added to the pages and I am sure this is the easy part.

Does anyone know if this is possible? If so, which approach would be the most efficient?

Thanks for any help you can shed on this subject. Also, sorry if the title is not good enough... I couldn't figure out how to explain it simply.

share|improve this question
add comment

2 Answers

I think this is definitely possible. I can't give you a full working example, but here are a few thoughts-

  • You could probably make services a taxonomy, then adding a service would be a matter of adding a new term to the tax.
  • you could make articles a custom post type, and associate each post to a service term to attach it to that service.
  • use the post_type_link filter to generate the URLs for each article post under the associated service. see this answer for an example.
  • you could also possibly make service sub-pages a custom post type. you may have to play with the order you register things to get the rewrite rules in the correct order of precedence, or you may need to write some rules manually.
share|improve this answer
    
Thanks for your suggestions. I was able to find a solution to this problem and I feel it fits my needs perfectly. I will update the post with what I did to solve this issue. :) –  Jeremy Sep 27 '12 at 15:24
add comment
up vote 0 down vote accepted

I was able to solve this by using custom post types. I created a Services custom_post_type and I created a template meta box to allow me to assign special templates to the pages.

The way this is implemented is:

Parent pages in Services are the services we offer. Under the parent page is a list page that uses the list page template for this custom_post_type (just displays a list of all children of the post). I then wrote a script that will add the posts to the database (since the data is in a different database and I wanted to take advantage of the sitemap). The list sub-pages (profiles) store the page slug and the title of the page with a small excerpt. I then just post content (articles) in the Services of the parent that the posts needs to be in.

This allows me to have multiple services while still being able to customize each service template (mainpage, list, profile) and it allows me to post articles to each service. I used Breadcrumb NavXT to have the breadcrumbs in the Services pages (To show the Services page instead of Home).

I know there are numerous ways to implement this but I wanted to keep the Services content away from the main site's content. That was why I wanted to use a custom_post_type. The only thing I was disappointed in was that WordPress would not let me use the default custom template option that you typically have for pages (using the page-attributes support tag. Yes, I had 'hierarchical' => true and 'supports' => 'page-attributes'). I provided my custom post type custom template code in the beginning of this response to help other that have this same issue.

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.