You have the ability to get the taxonomies for a given post type. Using the object_type parameter, you can specify that you want to get all the taxonomies for whatever post type. For example, let’s say you want the ones for the Posts. You’d do:
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Review and Commit Changes
Let’s talk through what you’ve accomplished in the archive template episodes. You’ll add another FAQ too. Then let’s commit the changes to your GitHub repository. You’ve made a lot of changes. It’s time to commit them.
Planning the Taxonomy
We need a way to categorize the content within the FAQs. Right? Categorization allows you to group the FAQs together for displaying them. For example, look at our Help Center. Each article is grouped and then displayed by a specific topic. We have Pre-Sales, Billing and Payments, and more. These topics are terms. These terms are bound to a custom taxonomy. Therefore, we want to build a custom taxonomy. Let’s call it “topic.”
Flushing the Rewrites
Now we need to handle flushing the rewrites when our plugin is activated or deactivated. We covered this topic in the Flush Rewrite Rules of the Custom Post Type Basics lab. In that episode, I showed you why you never ever want to flush the rewrite rules after your register a custom post type. Where should we put the activation and deactivation callbacks? Hum. Let me show you a couple of different strategies. As this is a module, we’ll opt to add the callbacks within the module itself. Why? It keeps everything together when you reuse this module. Pop Quiz […]
Configuring the Custom Post Type Options
Next, our custom post type needs further options to be configured, such as the menu icon and archive. Let’s walk through the different options.
Configuring the Custom Post Type Feature Supports
Out-of-the-box, when you register a custom post type, the feature supports are title and editor. That’s it. Hum, what if there are additional supports that you want, such as SEO or other custom ones from other plugins? If you have the Genesis framework installed, then it adds 3 feature supports. If you are using Yoast SEO, then it adds 1 feature supports. How do you specify these features when you build your plugin? You use the configuration code that you wrote in Exclude Post Type Features episode, as part of the Custom Post Type Basics lab. That code is reusable […]
Configuring the Custom Post Type Labels
The arguments for registering a custom post type are configurable to customize the experience and implementation for your needs. Part of that configuration are the labels. The labels are in the back-end. By default, they will use ‘Post.’ Hum, that will not make sense for the user, content strategist, and anyone who is in the back-end adding, editing, or managing the content. Our job is not just to write code. Nope, you are building experiences. It’s our job to make sure what we build is self-documenting, user-friendly, and draws people in to want to use it. Configuring the labels customizes […]
Build the Basic FAQ Custom Post Type
Let’s build the basic FAQ custom post type. We need to simply register the post type with WordPress. You already did this task in the Custom Post Type Basics lab. Right? Therefore, you have the basic boilerplate code that you can reuse. Let’s copy the code from this lab, which you can find in this GitHub repository. Then we’ll adjust it for our needs. Let’s also talk about how to make this code work within the module, i.e. so that it’s reusable for the plugin that it’s embedded into it. How can we make the text domain reusable? Let’s talk […]
Module Architecture
Let’s think about the architecture for this module. How are we going to break up the code into sub-modules, feature sets, and sub-functionality? In this episode, you and I are walking through how to break this module down into its components and keep it centered on a single intent or purpose. How do you break things up and architect your plugins, frameworks, applications, etc.? Focus on the intent and purpose. List out the big buckets of what you’re going to build. Then group the like items together into a logical order where each one supports the single intent of the […]
Wrap it Up
Way to go! You learned about the different post types and features that are built into WordPress Core. You saw how to check, add, and remove post type features. You saw an example with Genesis of how to add a new post type feature, one that is not built into Core. This lab will help you to do more in your own projects. It also serves as a baseline foundation for custom post types.