Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Shortcode View File
Lab: PHP Output Control and Buffer Basics
Video Runtime: 10:04
Using the same strategy, let’s apply it to a shortcode. In this episode, you’ll do the following:
- Move the HTML out of the shortcode function and put it into a View file
- Start the output buffer
- Load the view file
- Then get the HTML out of the buffer, clean the buffer, and return it back to WordPress
You are leveraging the PHP output buffer to separate out the HTML into a view file. Why? We’ve covered that many times. However, for you, it’s so much easier to deal with native HTML instead of placing it into strings and storing it into a variable. It’s more readable, easier to work with, easier to debug, and so on.
Break. Go rest your noodle for a couple of minutes.
Total Lab Runtime: 00:44:16
- 1 Lab Introductionfree 07:54
- 2 Setting Up the Labfree 08:24
- 3 Add HTML to Content and Return it Backpro 13:38
- 4 Shortcode View Filepro 10:04
- 5 Wrap it Uppro 04:16