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.

For a website I am developing I have to create two pages with listings of courses. The first page is a "Trainings" page while the other page is "Coaching". I would like to use a single custom post type for the content of the courses, because this will be the same for the all the courses on the Trainings and Coaching listings.

I also need to assign each courese to a sub category. These sub categories will only be used to display the courses in separate columns on the Trainings and Coaching pages, but the user should be able to specificy the sub category for each course, however, a course should only be allowed to have a single sub category.

The URL structure I would like to have is the following:

Trainings > Training category 1 > Training one ==> /trainings/training-one

Trainings > Training category 2 > Training two ==> /trainings/training-two

Coaching > Coaching category 1 > Coaching one ==> /coaching/coaching-one

Coaching > Coaching category 2 > Coaching two ==> /coaching/coaching-two

I am new to Wordpress so I would like to know what would be the correct Wordpress way to go about this.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

There are several ways to set this up. I´ll explain how I would do it, using as much of WordPress default settings and functionality to keep things simple.

Post Types

I´d start with creating 2 custom post types: trainings and coaching. The name of the post type will be added to the URL, so now your courses are accessible via:

example.com/trainings/postnamename
example.com/coaching/postname

Taxonomies

To group the courses together you can create custom taxonomies.

You didn´t specify how you want to order these posts and if the taxonomies are the same for both courses but let´s say you want to order all trainings courses by level: beginner, intermediate and advanced.

In that case you could create the taxonomy level containing the 3 terms: beginner, intermediate and advanced.

When you register the taxonomy you can specify which post types can use this taxonomy and what the URL should look like.

Use something like this:

 register_taxonomy('levels', array( 'trainings' ), array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array( 'slug' => 'trainings/level', 'with_front' => false ),
  ));

to generate URL´s like this:

example.com/trainings/level/beginner      // taxonomy archive of all beginner courses
example.com/trainings/level/intermediate  // taxonomy archive of all intermediate courses
example.com/trainings/level/advanced      // taxonomy archive of all advanced courses

Note that WordPress needs the name of the taxonomy (level) to distinguish a taxonomy from the course post type.

I hope this helps. Also as said before, I´m sure there are more ways to approach this.

share|improve this answer
    
Ok thx for your input. But an approach with a single custom post type is not possible? Or is this just the easiest way to implement it? –  Jan-Henk Aug 9 '12 at 16:04
    
Sure, a single CPT is possible, but then you´d end up with URLs like example.com/category/trainings/postname. You can remove the category prefix with a plugin, but I´m not sure how to add the taxonomies under the categories. Maybe it´s easy, just never tried it that way. –  Mattvic Aug 9 '12 at 16:17
    
I took the two custom post types approach. –  Jan-Henk Aug 13 '12 at 11:48
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.