Out-of-the-box, WordPress does not provide the editor or a means to render the contents from the page that is assigned to the Posts Page. Adding a blog introduction before all of the posts are rendered improves the user experience, allowing your client to explain the intent of the blog or do a call-to-action.
In this lab, you will build a real-world custom plugin which does the following:
- Turns on the editor for the Posts Page.
- Inserts the content from that editor into the top of the blog page.
As an example, our blog page is the Insights page. Notice how we framed the page title and an introduction.
When you complete this lab, you will have a fully-functional, custom plugin that you can use in any of your projects. You can improve it, add new features, and submit it to the WordPress Plugin Repository if you wish. The point is: you are building a real-world project in this lab.
This Lab is About More Than Building a Single Plugin
This lab is much more than just building a single, use-case plugin. Throughout the lab, you are learning valuable programming skills which make this lab adaptable for your projects and code. You are learning these and so much more:
- Custom plugin – writing it from scratch
- Unregister callbacks
- Investigate a theme
- Genesis
- Sanitizing
- Views
- Database and SQL
- Code construction
- Clean code
- Software principles
- How to think about code
All of these, especially the last four, are essential to you as a software developer. This lab gave you knowledge and skills that you will use in everything you do. When you get done with this lab, you will gain skills and knowledge you just can’t learn anywhere else. Plus, you get a plugin that you can use in your projects.
Works with Any Theme
In this lab, you will see me using the Genesis framework and child theme. However, this lab works on any theme. If you do not have the Genesis framework, no worries. You can use your theme of choice and then locate the proper spot or event in the theme to register for adding in the contents.
Prerequisites
In order to do this lab, you will need the following:
- Complete the Let’s Build a Basic WordPress Plugin lab.
- Turn on your local web server (Local, VVV, MAMP, WAMP, DesktopServer, or whatever).
- Open up your favorite editor.
Code. Eat. Code. Sleep. Dream about Code. Code.
Episodes
Total Lab Runtime: 02:56:19
- 1 Lab Introductionfree 03:25
- 2 Plugin Architecturefree 04:59
- 3 Convert the Basic WordPress Plugin into a Blog Intro Pluginbasic 11:46
- 4 Turn on the Editorbasic 12:47
- 5 How Does WordPress Turn off the Editor?pro 12:00
- 6 Locating Where to Insert the Content in Your Themebasic 07:34
- 7 Genesis Posts Page Archivepro 09:39
- 8 Genesis Before Loop Event genesis_before_looppro 05:11
- 9 Render (Display) the Contentsbasic 06:01
- 10 How to Ensure It's Posts Page?basic 12:05
- 11 Let's Look in Core at is_homepro 11:41
- 12 Refactor Getting the Posts Pagebasic 08:58
- 13 Let's Look in Core at get_post - Part 1pro 13:42
- 14 Let's Look in Core at get_post - Part 2pro 04:10
- 15 Sanitize the Contentspro 10:14
- 16 Sanitize with get_postpro 10:56
- 17 Prepare the Contents for the Browserbasic 05:18
- 18 Building the HTML View Filebasic 09:32
- 19 Master Tip: Why Use a View?pro 05:01
- 20 Remove Genesis Page Titlebasic 05:12
- 21 Master Tip: How Did I Know to Use after_theme_setup?pro 02:37
- 22 Wrap it Upfree 03:31