At the bottom of each article, you are used to seeing the post meta. This is where Genesis, by default, renders out the post’s category(ies) and tag(s). This functionality occurs in the function genesis_post_meta in the file “genesis/lib/structure/post.php”. Part of this function, just like with the post info, the shortcodes are being filtered by an event, which is named genesis_post_meta, and then processed through the WordPress Core function do_shortcode(). This is the filtering event which fires to call any functions that are pre-registered to the event name genesis_post_meta: $filtered = apply_filters( ‘genesis_post_meta’, ‘ ‘ ); Within Genesis, it has registered […]
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 Footer – Overview
After the entry content and still within the <article>, Genesis provides the ability to display additional content. This is the entry footer section. By default, Genesis will render out the post categories and post tags and the post meta. In this episode, you see each of the callbacks which are registered to build the entry footer HTML markup. The event name for this section is genesis_entry_footer.
After Entry Content
Genesis provides you with an event where you can add content between the entry-content and entry-footer HTML markup areas. To use this event, you will register your function (callback) to the event name genesis_after_entry_content. In this episode, you’ll see where to use it and where the content would occur with the HTML markup on the web page in the browser.
Entry Content – Post Permalink
What happens on an archive page when a post does not have a title? Did you know that the Genesis framework has a default registered function called genesis_do_post_permalink, which is found in genesis/lib/structure/post.php? What will happen is: Genesis adds the permalink and some HTML markup after the content and post navigation. In this episode, you’ll walk through the function to understand how it works. For the customization exercise, you’ll again use the PHP construct called str_replace() to add some prefix label to the link.
Entry Content – Post Content Navigation
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 […]
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.