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.”
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 […]
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.
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 […]
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 […]
Let’s talk through what we are building together. Start with the Scope of Work, i.e. the big green box on the lab’s landing page. You’ll build the following: A custom post type called ‘faq’ A custom taxonomy for it to give us the grouping topics Add the page attributes to the custom post type to give us the ordering feature An archive page and custom loader We’ll use the SQL and $wpdb from the Advanced SQL lab. Then we’ll modify it for our needs. A shortcode with two different processes We’ll build it in that order, step-by-step. You are building […]
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.
Let’s commit our changes to the GitHub repository. Congratulations!
Let’s activate our plugin and the UpDevTools plugin. Then you’ll add the shortcode into a post. Let’s test that it works. We’ll walk through the code and see the configuration and attributes. We’ll do some testing on different options and iterations. Before we finish, let’s commit our changes to your GitHub repository.
Let’s discuss the plugin architecture and build the folders and main files. We’ll think about the intent of the structure and each component. We’ll talk about why you want to build your code in modular format that complies to Single Responsibility Principle. Let’s build our file structure.