In this episode, you will learn about what makes a taxonomy a custom one. We’ll discuss the what (what is it), why (why you want to use it), and when (when you want to use it versus the built-in taxonomies).
What makes a taxonomy custom? Think about it. It’s when you add a new taxonomy that is not included and built into WordPress. That’s it. That’s what makes it custom. You are extending WordPress by configuring a specific one for your project’s needs. Then you attach that taxonomy to one or more post types.
Why would you want to create a custom taxonomy? WordPress has categories and tags built-in for you to use. But what if your project has a custom post type and it needs a grouping mechanism that is not the same as your blog posts. For example, with our team bios, if we add “category” to the post type, does that make sense? Are categories for the blog posts the same categories for the team bios? No. Let’s add the category to our team bios custom post type and I’ll show you why.
When to create a custom taxonomy? When you have a custom post type that needs its own specific grouping mechanism.Use a custom taxonomy when a post type needs its own specific grouping #WordPress #AhaMoment Click To Tweet
For example, let’s say you are building a website for a real estate developer, a company that builds subdivisions, homes, and condos. They want a custom post type for their home models. Their blog posts are more marketing-centric, helpful tips on financing, community, cool new features, etc. The home models are not related to that content. Therefore, you would want to separate out the content and provide a custom experience.
You might use a custom taxonomy for identifying some major classification such as the location. Then you’d build custom metadata (fields) for the specific attributes such as the number of bedrooms, baths, and garage stalls as well as square footage, the number of floors, type of home, etc.
Your functions are bloated. Put them on a diet. Think "skinny" and "as few lines as possible."
Total Lab Runtime: 01:30:53
- 1 Lab Introductionfree 08:15
- 2 Custom Taxonomy - The What, Why, and Whenfree 08:32
- 3 Registering a Custom Taxonomypro 09:54
- 4 Configure the Labelspro 14:51
- 5 Bind to Post Typespro 11:55
- 6 Configuring Argumentspro 07:52
- 7 Render Entry Footer Termspro 08:40
- 8 PHP 101: Concatenating Assignment Operatorpro 02:26
- 9 PHP 101: Building Stringspro 08:19
- 10 Test Entry Footer Termspro 03:03
- 11 Flush Rewrite Rulespro 03:56
- 12 Wrap it Uppro 03:10