I have a hard time figuring out how to structure a site. The site is a news site for 3 different, but related sports: Skateboard, Snowboard and Surfing. Each Sport has typically Athletes, Event names, Locations, Brands, Photographers, Film Makers and Tricks attached to them.
Mostly we publish news about these sports through articles, pictures and videos, and what I am aiming for is to be able to extract data from these published items and present them on pages grouped with similar data.
An example: We have written an article about Tony Hawk (Skateboard Athlete) performing the first ever 900 (Skateboard Trick). We would like that article to be listed on a page called Skaters (Skateboard athletes) where all skaters are listed in an alphabetical order, where Tony Hawk has his own section under the skateboard category, and for the same article to be listed on a page called Tricks with other 900s and other skateboard tricks. But the article cannot be listed under e.g. Snowboard tricks or Surf Tricks.
The way I have set it up is that I made 3 Custom post types for each sport, and custom tags under each sport for Athletes, Event names, Locations, Brands, Photographers, Film Makers and Tricks, which means there are e.g. 3 different tags for Tricks (Skateboard Tricks, Snowboard Tricks and Surf Tricks).
However, I have come to realize that if I follow this system further, I would need 3 custom post types for image galleries, 3 custom post types for events and so on, just making the admin pretty unuserfriendly.
The alternative would be to set up a hierarchical category system, where e.g. skateboard is a parent category, Skateboard trick is a child category, and the various trick names would be grand children categories. However, that to my understanding, would create a long long list of categories to choose from in every post.
The best thing would be if I could just make a relationship between custom tags and child categories, instead of a relationship between custom tags and custom post types, but I understand that is not for wordpress.
So my questions is: What is the best structure for my site? Any ideas that are more userfriendly?
I think you have misinterpreted custom post-types and custom taxonomies, somewhat.
Theory
Custom Post Types
I consider the purpose of a custom post-type to be format of data distinct in it’s own right – it describes a type of content, but not the content itself. Take the in-built page
, post
, and attachment
post-types, for example:
- The
page
post-type describes the format of a generic, static page on a website that may be organized into a hierarchy using parents.
- The
post
post-type describes timely content that may be organized with
categories and tags that reflect the nature of the content itself, and generally emphasize community with comments. Posts are also published in RSS feeds for visitors to digest externally.
- The
attachment
post-type describes a media file which is associated with one of the aforementioned post-types.
It wouldn’t make sense to publish “About Us” content as a post
(the chronology of when the content is published is irrelevant, and it is unusual to have a comments section on such static content), nor would it make sense to publish a news story as a page (it is important when the story was published, and it would be useful to use taxonomies to describe what type of story it is). Neither piece of content could reasonably be published as an attachment
.
It would be even stranger to create a unique post-type for each piece of static content (an “About Us” post-type, a “Contact Us” post-type, a “Privacy Policy” post-type, etc.) as each piece of content could be described in an identical format.
Any data relevant to a custom post-type is most frequently stored and accessed via the Metadata API, which allows you to attach custom information to posts.
Custom Taxonomies
A taxonomy is nothing more than a method of grouping items together. In practice, you can taxonomies to organize varieties of content, or to reflect certain aspects of content – whether that content is described with the same post-type, or different ones.
A site listing television shows and movies may have a custom post-type for both (as an episodic television show is described in a different manner than one describes a movie), but entries of either could be classified using the same genre
taxonomy (the entries or “terms” of which would contain things like “sci-fi,” “horror,” “action” etc.).
Application
Hockey, basketball, and football are all by definition a type of sport, and therefore can be described in the same format as any sport can (a name, a ruleset, a history, etc., for example). As a result, it follows that you should create a single sport
custom post-type, and create three individual entries of the sport
post type to represent each individual sport.
By the same logic, it stands to reason that a single athlete
post type will sufficiently encompass participants in all sports, and a single event
post type will address any event for any sport, athlete, etc.
sport
s could be organized with a taxonomy that describes the type of sport – i.e. “spectator sport”, “team sport”, “competitive sport”, “amateur sport”, “water sport”, “professional sport”, etc. However, for your application this is unnecessary.
Events are organized (or grouped) by location, so it makes sense to have a location
taxonomy that applies to the event
post-type. It could be hierarchical by geography (state or province terms having city terms as children, for example) – allowing you to query events by city or region – or simply flat-level like a tag.
Both events and athletes may be organized according to their associated sport, so it makes sense that in addition to the sport
CPT, a sport
taxonomy would be created (and not applied to the sport
CPT. Alternately, the Metadata API could be used to associate items with the respective sports
CPT entry.
However, from your description, it sounds as though you are not interested in describing any of the sports on your site – you have no need for actual pages detailing aspects of a sport independent of the people, places, and events related to it. As a result, it would make more sense to not have a sport
CPT at all, and rather only a sport
taxonomy, allowing you to group athletes
and events
by their respective sport.
Summary
I believe the best way to organize your content is as follows:
- Custom Taxonomies
- Custom Post-Types
athlete
– uses the sport
taxonomy
event
– uses the sport
and location
taxonomies
A query with the following arguments returns the archive page containing all athletes participating in football:
$args[ 'post_type' ] = 'athlete';
$args[ 'tax_query' ] = array(
'taxonomy' => 'sport',
'terms' => 'football'
);
This query is always available at the URL
/?post_type=athlete&taxonomy=sport&terms=football
How that translates into a pretty-permalink is dependent on your permalink settings and the slugs you chose.