Let’s go deeper and head into Core to look at get_post. This function is going to either pull the post content from the database or cache. In this episode, you will learn about both and reverse engineer the function to discover when it’s pulling from one or the other. As the function is dealing with the database, it’s time to teach you some SQL. You will play around with the database to see how to pull records. I use Sequel Pro, but you can use phpMyAdmin to do the same exploring of the database. Here are additional resources about PHP […]
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Let’s Look in Core at
Refactor Getting the Posts Page
Let’s refactor how you are getting the posts page object by abstracting it into a separate, reusable function. Then you’ll add in protection to ensure an object is received back from the database before continuing the processing. You will be learning about clean, quality code in this episode too. You will learn about the Falsey Conditional Expression.
Let’s Look in Core at
Let’s go into WordPress Core and talk about how is_home() works. You will also learn about objects and OOP in this episode, as is_home() is a wrapper around the instance of WP_Query. You can also see this hands-on lab to learn the differences between is_home and is_front_page:
How to Ensure It’s Posts Page?
You only want the contents to display (render) on the Posts Page and that’s it. In this episode, you’ll learn how to ensure you are on that page. If no, then return early and stop processing; else continue with the rendering. You will learn about clean, quality code too. You will learn about is_home.
Render (Display) the Contents
Let’s get the contents out of the database and then display (render) it onto the page in the browser. You’ll walk step-by-step through the process. You will learn about get_post.
Genesis Before Loop Event
From the previous episodes, you identified genesis_before_loop as the event you need to register your callback in the plugin in order to render out the content into the right spot on the page. Let’s talk about this event. In this episode, you’ll walk through the basic structure of Genesis, looking at the function genesis(). You will also look at the Loop in Genesis in order to gain a general understanding of where this event places your content into the HTML structure.
Genesis Posts Page Archive
Let’s dive deeper into the Genesis framework by StudioPress. You will learn about: the posts page archive rendering Genesis markup and genesis_attr – overview and intent HTML attributes
Locating Where to Insert the Content in Your Theme
Let’s figure out where we can hook into the theme to add the content from the editor. Each theme will be different. You will need to evaluate your theme in order to determine where you can hook into for rendering out the content. In this episode, you will look at two themes. First, you will dive into the Genesis framework and look at where the page title is being rendered for the Posts Page, i.e. found in genesis/lib/structure/archive.php. You will see which event you need to register to in the plugin in order to add in the content. Then you […]