Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Build the Shortcode – Single FAQ
Lab: Add a FAQ Feature to the Collapsible Content Plugin – Part 2
Video Runtime: 21:19
Let’s start building the shortcode processor for the single FAQ, i.e. when the shortcode user-defined attribute specifies a single post ID to display. You and I will look at what we receive as user-defined attributes when processing the shortcode. We’ll look at the configuration parameters. We’ll think about different scenarios of how to process when we don’t receive a post ID or topic as well as when we receive an invalid post ID.
This episode is heavy PHP fundamentals. We’ll talk about:
- ternary operator
- variable scope
- variable scope when including a file
- type casting from string to integer data type
- grabbing a value by the keys within an associative array
- and more.
Whoops, we discover a problem
As we are building this processing functionality, we’ll discover that our assumptions for the architecture are wrong. What if the post ID is invalid and we don’t get back the post record when doing get_post()
? Hmm, that’s problematic. Why? Because the HTML that is rendered out has the <dl>
but nothing within it. That’s invalid HTML markup. Whoops. Instead, we have to rearchitect the shortcode to deal with this problem. We’ll do that in the next episode.
You get WET when you swim. Stay DRY when you code.
Episodes
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