Oh man, your head should be huge now as you learned so much in this 5 hour, two-part hands-on lab. But the Loop is the key concept in WordPress. I’m proud of you and here’s a personal message from me to you.
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.
The Loop Else – No Posts Found
If there are no posts available for the criteria, you want a message to alert the reader. Genesis provides you with both an event called genesis_loop_else and a function genesis_do_noposts which provides this message. You can customize the message by using the filter genesis_noposts_text.
After the Loop – Archive Posts Navigation
On archive pages, such as the Posts Page, you want a way to navigate to the additional posts. Genesis provides pagination in two different formats: previous and next links or numeric. You select what you want in the Genesis > Theme Settings > Content Archives meta box. Let’s walk through this code.
Customize the Previous and Next
Now you know how to turn on the previous and next links. In this episode, you will be customizing it by changing the previous link text, adding a class attribute, and moving the post title to another line. Here is the code you will build and I will explain in this episode:
Turning on the Adjacent Entry Nav – Previous and Next
After the article, you want to give readers the ability to discover more content easily and quickly. One technique is to use the Previous and Next links which allow the reader to navigate to the adjacent content. Genesis provides the functionality to use these links, but it is not enabled. Nope, you need to turn it on in your child theme. This episode walks you through two different ways to turn on it, as well as you will walk through the code. Note: The comment in the DocBlock of Genesis says to use a priority of 10 or less to […]
After Entry Widget Area
Let’s go through the function genesis_after_entry_widget_area() in Genesis, as it is responsible for building and then rendering out the widgetized area for the “after entry widget area.” You’ll explore how the ! operator in PHP works as well as looking at the conditions which say, Yes let’s go ahead and render it out. For the customization part of this episode, you will walk through different techniques to turn off (remove) this component. Let’s say you don’t want the after entry widget area in your theme. Ok, this episode discusses how to properly disable and remove this component.
Reorder Author Box & After Entry Widget Area
Let’s do some customization by reordering the author box and after entry widgetized areas. I’ll show you two different ways to move these components such that the author box is after the widgetized area. You’ll also learn about why you need to unregister the Genesis callback by using remove_action, as you see the callbacks in the WordPress Core Plugin API’s event registry table, which is stored in the global variable $wp_filter. To learn more about the WordPress Event-Driven System and the Plugin API, see the following labs and Docx: WordPress Plugin API – Introduction & Registering Events add_action remove_action do_action
After Entry – Overview
Right the <article> is closed, Genesis provides you with the genesis_after_entry event hook. Out-of-the-box, the framework adds the following components: Author Box After Entry Widgetized Area Previous and Next Navigation (adjacent entry nav) Comments You can see the execution order within the Genesis loop here: In this episode, you’ll walk through the codebase to get an overview of the above components.
Entry Footer – Post Meta
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 […]
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.