In this hands-on lab, you and I will walk through the entire process of adding a new feature to an existing WordPress plugin. You’ll start with the Collapsible Content plugin and then add a FAQ feature to it. This feature will require you to build a custom post type, custom taxonomy, custom archive, advanced SQL queries, and shortcode.
New projects that use a lean and agile approach build out a feature and then ship it. It’s an iterative process of pulling features off of the product backlog and then repeating the process of build and ship. Learning this process will help you to ship early and ship often. It will also help you to learn how to add a new feature to an existing plugin.
Let’s go to the Product Backlog and grab this feature. Together, you and I will plan out what this feature is and how we’ll build it. Then we’ll build it together, step-by-step-by-step. We’ll talk about the strategies, architecture, and how to think about building the code. I left in the errors and problems that occurred to help you see the entire process. This lab simulates you and me sitting side-by-side building this plugin together, errors and all.
FAQ Feature from the Product Backlog
Expand the functionality of the Collapsible Content plugin by adding a Frequently Asked Questions (FAQ) to it. This feature allows the creation of a new type of content, FAQ. The FAQs will be grouped by the type of question, i.e. topic. Then all of the FAQs will display on an archive page in a configurable order, as set by the client.
In addition, this feature will provide the means to embed a single FAQ or a group of them by a single topic into any piece of content on the website.
Want to cheat and see what you’ll be building with me? Okay, here’s a link to the GitHub repository.
What You Will Learn
What will you learn in this lab? Well, you’ll be learning how to plan, think, and execute building in a new feature. More specifically, you will learn:
I strongly suggest that you first do each of these hands-on labs. Part 1 builds the plugin and the basic features. The post type labs get you up-to-speed with the built-in post types and custom post types.
One of the features is to group the FAQs by their assigned topic (the custom taxonomy terms). This feature requires some advanced SQL, which you built in the Advanced SQL – Get Posts Grouped by Terms lab. In order to understand what’s going on, I suggest that you do these two labs as well. If you choose to skip these two labs, go back when you have time.
Don’t repeat yourself. Don’t repeat yourself. Don’t repeat yourself.
Total Lab Runtime: 05:11:56
- 1 Lab Introductionfree 07:51
- 2 Planning it Outfree 11:05
- 3 Module Architecturepro 17:12
- 4 Build the Basic FAQ Custom Post Typepro 06:04
- 5 Configuring the Custom Post Type Labelspro 18:33
- 6 Configuring the Custom Post Type Feature Supportspro 07:23
- 7 Configuring the Custom Post Type Optionspro 11:27
- 8 Flushing the Rewritespro 09:44
- 9 Planning the Taxonomypro 04:54
- 10 Build the Taxonomypro 05:33
- 11 Taxonomy Label Generatorpro 14:23
- 12 Flush Rewrite Rules - Taxonomypro 05:36
- 13 Architecting the Archive Pagepro 11:14
- 14 Serve Archive Template from the Pluginpro 10:41
- 15 Let Theme Override Our Archive Templatepro 21:29
- 16 Build the Archivepro 11:09
- 17 Build the Archive Viewspro 13:23
- 18 Set the Order Within the Topicpro 03:44
- 19 Review and Commit Changespro 02:34
- 20 Architect the Shortcodepro 15:23
- 21 Build the Shortcode - Single FAQpro 21:19
- 22 Fixing the Architecturepro 08:00
- 23 Define a WP_Query for Topicpro 16:10
- 24 Continue Building the Shortcodepro 11:39
- 25 Finish by Topic Shortcodepro 08:51
- 26 Planning the Refactorpro 08:01
- 27 Refactor FAQ Modulepro 19:58
- 28 Test, Fix, Commit, and Wrappro 08:36
One of our jobs is to build quality code that is reusable again and again without changing the codebase. Ideally, we'd like to configure what's different and have the codebase the same for all of our projects. In Part 3, you will convert the Collapsible Content plugin into the ModularConfiguration design pattern by moving all runtime configurable parameters into configuration files Then the codebase will be made reusable. The actual implementation then is determined by the configuration file that's loaded. This approach will save you time.
Check out the Plugin Development Library for more hands-on labs, insights, Docx, and more.
Check out the series page for more labs: Collapsible Content Plugin Series – WordPress Plugin Development A-Z