Now let’s walk through and test our module. In doing so, you’ll find that we need to change the taxonomy’s registration as we don’t want to show it on the front-end. Let’s make that change. Then we’ll commit the final changes to your GitHub repository. I have to say how proud I am of you! Seriously! You worked right along with me. I know it was a long lab. The whole point was to walk you through the entire process of building a new feature module, step-by-step. I hope you learned about WordPress, PHP, Plugins, HTML, and more. We covered […]
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.
Set the Order Within the Topic
Remember that one of the requirements is to add the ability to set the order for the questions within each topic. For the custom post type, we added the page attributes feature in order to gain access to the menu order. In this episode, let’s change our SQL to order by both the term ID and the menu order. We’ll also take a look at the database too. You’ll be amazed at how easy it is now to add this feature.
Taxonomy Label Generator
What if you had multiple taxonomies? Think about that. What if you needed to add a “topic” and “faq-categories” for example? Using the current code, you’d copy the label generation code and copy it into the next taxonomy you are registering. That’s a lot of code. Instead, let’s build a label generator. Then you can call this function for any of your custom taxonomies. The code remains the same. The only thing that changes, typically, is the specific name. Why do this? It makes your code more readable and reusable. It speeds up your development time and reduces your costs. […]
Flush Rewrite Rules – Taxonomy
Right if you were to view one of the new terms, you’d get a 404. Why? Think about it. Why does it give you a 404? Because you need to flush the rewrite rules. You can do this by going to Settings > Permalinks and clicking on “Save Changes” button. But for a real plugin, you won’t want to have your customer install, activate, and then have to go to Settings in order to get the taxonomy and custom post type to work. Right? Instead, you want to handle it within the plugin. In this video, you’ll add the taxonomy […]
Build the Taxonomy
In this episode, you and I are going to build the custom taxonomy code. We’ll use the code from the Team Bios plugin that you built in the Custom Taxonomy Basics lab. I want to show you just how easy it is to take boilerplate code and then configure it for another custom taxonomy. It literally will take you less than a minute and then bam, you have a custom taxonomy.
Let’s talk about what you are going to do and build in this lab. We’ll talk about why. Why are we adding this FAQ feature? We’ll talk about what you’ll learn and the expertise you will gain after doing this lab with me. This lab is awesome. It has advanced plugin development concepts and processes. It will help you to move forward in your plugin development career. Don’t worry. I’m going to walk you through the entire process, sharing how I’m thinking about it, why we’re going in a particular direction, and alternative strategies. Ready? Let’s get to work.
The What Syntax get_taxonomies( array $args = array(), string $output = ‘names’, string $operator = ‘and’ ); WordPress codex Description This construct (function) gets all the registered taxonomies and returns them as an array of names or objects. The taxonomies are stored in the global variable $wp_taxonomies . You specify whether you want to receive the list back with the names or the post type objects. Keep in mind that when you call this function, it is fetching all the current registered taxonomies. Parameters args Array of arguments to specify what you want to receive back from the request. The […]
Advanced SQL – Get Posts Grouped by Terms
This hands-on lab teaches you more advanced SQL including table relationship types, how to join multiple tables together, and how to write SQL queries that are faster and more scalable for your WordPress projects. You will use a practical example plugin to test two different approaches to solving the problem of fetching posts that are grouped by each term. You’ll test these approaches, explore the actual SQL queries, and learn about the impact of processing speed, performance, and scalability.
WordPress Tip – Linking Taxonomy to Custom Post Type
Do you need to include the optional parameter taxonomies when registering the custom post type register_post_type()? How do you link the taxonomy and post type? In this quick tip, Tonya shows the how and why of the `taxonomies` optional parameter.