What is the difference between custom taxonomies and page templates and custom post types?
I think I understand that taxonomy is used to organize data. CPTs are used to give your data a different design.
but can’t a template be used instead of CPT? or are they used in combination?
and can’t categories be used instead of creating additional taxonomies?
i guess are CPT’s and custom taxonomies just tools to make life easier or do they serve a purpose that could not be achieved without them?
I have been creating new templates for any page the needs a different look or any page that uses a specific category. have i been doing this wrong or poorly? instead of having 7 templates should i have 7 CPT’s or something like that?
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Taxonomies are categorizations of data. Tags are a taxonomy. Categories are another taxonomy. If you are building a movie website and want to show which actors starred in which movie, “Movies” would be a custom taxonomy.
Custom Post Types are really just custom data items. They’re stored just like posts and pages, but aren’t considered the same thing as a post or a page. In the movie website example above, “Actor” might be a custom post type with a Name, a Biography, and a Headshot as elements.
Custom Page Templates are special files for WordPress that dictate how the content will be laid out on the page. They’re used strictly with pages in WordPress, not with posts or custom post types.
Think of it this way:
Types of Data:
- Menus (yes, these are a custom post type)
- Custom Post Types
Ways to Structure and Relate Data:
- Post Formats
- Custom Taxonomies
Ways to Present Data:
- Custom Page Template
It’s one of the cases of name that is slightly confusing. Think of Custom Post Type as Custom Content Type instead.
Simply put CPT doesn’t have to be post at all. Actually the main purpose of CPT is to give an option to build things partially or completely different from generic posts.
Of course you can hack posts to be many things as well, but CPT mechanisms give more controls and more clear distinction between different types of content.
So if you just need different looking page – custom template is absolutely appropriate tool.
categories are a taxonomy, and can be used instead of additional taxonomies. but where additional taxonomies come in is when you need more than just a single means of categorizing things, or you want them separated.
custom post types are for different content types. they not only can be treated differently on the front end, but they are displayed separately and can be handled different on the back end.
if the differences are superficial, then templates is the way to handle things. if they’re separate things like a post vs a product vs a person, then custom post types are the way to handle it.
also have a look at post formats for handling different formats on the front end.