Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Continue Building the Shortcode
Lab: Add a FAQ Feature to the Collapsible Content Plugin – Part 2
Video Runtime: 11:39
In this episode, we’ll continue building the shortcode for the topic. We’ll look move the while
loop to a new function to process the individual FAQs.
As we are building, notice that we have a decision to make: Do we display a message when no FAQs are found? Let’s do that. But instead of echoing at each message, let’s make it configurable and give access through the shortcode’s user-defined attributes. Then the author (or you) can turn it off and on as well as change the messages. This is a refactoring exercise for you.
We start off by making sure that we only get published FAQs with our query. You’ll look at the WP_Query
parameters to see what the default is for "post_status"
. Aha, it is set to "publish"
.
Pro Tip
Whenever a parameter is the value you want by default, don’t include it into your arguments. It’s redundant. Instead, only declare the custom ones.
Break. Go rest your noodle for a couple of minutes.
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