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.
Don’t repeat yourself. Don’t repeat yourself. Don’t repeat yourself.
Total Lab Runtime: 00:44:16