In this episode, you’ll take a look at the Genesis framework function genesis_do_post_content_nav, which is found in genesis/lib/structure/post.php. This function is setting up the arguments which are passed into the WordPress Core function wp_link_pages. The intent of this function is handle in post navigation, i.e. paginated posts. Did you know that functionality even exists? I’m also introducing you to a PHP construct called str_replace() which allows you to swap out parts of a string by searching for a given pattern. As part of your customization hands-on work in this lab, you’ll be replacing the “Pages:” string, which is hardcoded in […]
Labs
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.
Entry Content – Post Content
As part of the entry content, Genesis has a default registered callback for building the content based upon various settings (who you have it configured) and which web page is being displayed. The function is genesis_do_post_content, which is found in genesis/lib/structure/post.php. Looking at the function, you’ll see that there are four (4) different conditionals to determine what content is displayed: the web page is a single piece of content, i.e. is_singular() is true “excerpts” are set for the archive (because it’s configured that way in Genesis > Theme Settings) the archive content is being limited (because it’s configured that way […]
Real Refactoring Example
Even though I use and like Genesis doesn’t mean there aren’t areas where it doesn’t fully comply with clean, quality coding techniques. In the last episode, I showed you the code for processing the post image. Did you notice that the code within the function genesis_do_post_image() will not run (none of it) if the conditional expression is not true? Ah, this is a perfect example of when to return early. Return early pattern: when you are done processing and nothing else in the function/method is going to be processed, then so bail out and return early. Why? Why would you […]
Entry Content – Post Image
As part of the entry content, Genesis has a registered callback for building the post image. The function is genesis_do_post_image, which is found in genesis/lib/structure/post.php. By default it is set to a priority of 8, meaning it fires first before the content. The post image will go out to the browser if: this is not a singular page, i.e. is_singular is false, the option for the featured image is checked in Genesis > Theme Settings > Content Archives, and the article has a featured image. The magic of this functionality occurs within the Genesis helper function, genesis_get_image(). Let’s walk through […]
Entry Content Overview
The entry content is built and rendered out to the browser using the Genesis event hook called genesis_entry_content(), which is found in genesis/lib/structure/loop.php. Within the Genesis framework, this event has multiple callbacks registered to it in order to build the different elements of the entry content: Post image Post content Post content navigation for paginated posts Post permalink (for when there’s no title) You can use this event to reorder, remove, or add various elements. It gives you the means to customize what you want to be rendered within the <div class=”entry-content”> section of the page.
Before Entry Content Hook – genesis_before_entry_content
Genesis provides you with an event hook called genesis_before_entry_content(), which is found in genesis/lib/structure/loop.php. This event is available to you to a couple of different customization use cases: Rendering out content which is not part of the article’s (entry) header or content, e.g. social media buttons Pre-processing or preparation (prep) work before you do the entry content This particular event is fired in the loop within Genesis, but is not used anywhere else in the framework (at the time I recorded this). It’s there for you. It gives you a hook for customization.
Introduction to Programming
The common way to start in WordPress is to take a theme, modify some styles, and then copy some piece of code to customize a feature. Far too many people skip the elementary fundamentals which are the critical foundations of programming. In this hands on lab, you will be introduced to programming including learning about the intent of code, syntax, differences in languages, and more. Prerequisites You will need to have your local development machine setup and ready to go. See the series prerequisites for more details. In addition, you will to complete the first installment in the series: Introduction […]
The Loop Part 2 – Developer’s Guide to Customizing Genesis
This is the second part of the Loop. In this lab, you will explore how the remaining portion of the loop in Genesis works as well as how to customize it. You will dig into the entry content, footer, and after entry components.
Entry Header – Post Info
Within the entry header, Genesis provides the means for each article to have additional information. They call it the byline as well as post info, as it provides additional information about this particular article. Let’s explore how Genesis builds the HTML markup and what event hooks you have available to you to customize this information. In this episode, you are exploring the genesis_post_info() function, which is found in genesis/lib/structure/post.php.
Entry Header – Post Title – Part 2
This episode continues explaining how Genesis builds the HTML markup as well as where and how you can customize each part of the markup.