New Genesis 2.0 HTML 5 Loop Hooks & How To Use Them

You will need to add HTML 5 support to your Genesis child theme in order to make these new hooks work.

On top of this, the old XHTML markup in existing child themes will need to be converted to HTML 5 as well. Otherwise, you’ll probably find your site is messed up.

Once you’ve done all that, you can then change any existing loop hooks or use the new loop hooks in your child themes functions.php file with custom functions.

Genesis Hook Comparison

New HTML 5Old XHTML
genesis_before_entry genesis_before_post
genesis_entry_headergenesis_before_post_title
genesis_entry_headergenesis_post_title
genesis_entry_headergenesis_after_post_title
genesis_entry_headergenesis_before_post_content
genesis_entry_contentgenesis_post_content
genesis_entry_footergenesis_after_post_content
genesis_after_entrygenesis_after_post
Note: You must install Genesis 2.0 and add support for HTML 5 to your child theme before using the new hooks.

List Of All New HTML 5 Loop Hooks

Includes the 3rd parameter for positioning priority.

Old Loop Hooks

XHTML Loop Hooks

New Loop Hooks

html 5 hooks

Note: If HTML5 is not active, the genesis_loop uses the old hooks and XHTML markup.

Lets look at a real code snippet which is tested and works.

Example:

This code will add a widget area after single posts and pages using the new genesis_after_entry_content hook. That’s the only change in this code.

The code will NOT work unless you have added HTML 5 support to your child theme and activated Genesis 2.0.

Line 8 in this code shows you the new hook.

Simply updating to Genesis 2.0 is not enough to make this code work. The new hooks are dependent on HTML 5 supported child themes.

Old Hook Example

genesis_after_post_content

New Hook Example

genesis_after_entry_content

I’ll be posting more useful code snippets using the new hooks shortly.

Basic Functions Using New Hooks

Basic Functions Using Old Hooks

Useful Resources


Comments

34 responses to “New Genesis 2.0 HTML 5 Loop Hooks & How To Use Them”

  1. […] called – genesis_entry_footer, from which you need to remove post meta information. Apparently, this change happened in Genesis 2.0 when it made changes to adopt new HTML5 standards. Below code should work […]

  2. […] the new hooks when your theme uses the old ones: Using code which includes Loop hooks for sites still running the old XHTML markup on new sites doesn't work. The code will work on older […]

  3. […] Note: All PHP code uses the new Genesis 2.0 loop hooks […]

  4. […] Note: These hooks apply to themes using either the old XHTML & new HTML 5 markup and themes running HTML 5 are using different loop hooks. […]

  5. Kevin Donnigan Avatar
    Kevin Donnigan

    Thank you!!! I was trying so hard to figure out genesis_get_comments_template hook. Finally! 🙂 🙂

  6. Chris Avatar

    Brad,

    Thank you for this post. Can you help me with something perhaps simple?

    It looks like I can use genesis_before_post_content to create a unique widget area before post titles.

    But I also want a unique (and separate) widget area before PAGE titles.

    Will genesis_before_post_content end up using the same widget for posts and pages?

    Or is there a way to create a separate widget area for pages?

    Thank you,

    Chris

    1. Brad Dalton Avatar
      Brad Dalton

      Add this line after the function.

      For pages use:
      [code]
      if ( is_singular(‘page’) )
      [/code]

      For Posts use:
      [code]
      if ( is_singular(‘post’) )
      [/code]

      1. Chris Avatar

        Brad,

        Thank you!

        Chris

        1. Brad Dalton Avatar
          Brad Dalton

          You’re welcome Chris.

  7. Sharon Avatar

    I have a question. I’m trying to figure out how to stop my email subscription boxes from showing up in my category listings. I wanted it to show up only at the end of entire posts. I used the Genesis Entry Footer Hook. It is showing up in both places. It makes my category section really crowded when someone clicks on a particular category. Can you offer any help?

    1. Brad Dalton Avatar
      Brad Dalton

      You can add a conditional tag after the function in the code.

      You can use either:
      [code]
      is_single() ) or is_singular(‘post’) )
      [/code]

      Here’s an example http://wpsites.net/web-design/add-same-after-single-post-entry-widget-to-single-pages/

  8. Matteo Avatar

    Great tutorial.

    But if I want to add “facebook comments” BEFORE “wordpress comments form” but AFTER Author Box?

    1. Brad Dalton Avatar
      Brad Dalton

      No problem.

      Change the hook and add a 3rd parameter for positioning priority if needed. Default is 10.

  9. Jeremy Myers Avatar
    Jeremy Myers

    So if I do have HTML5 enabled, will the old hooks NOT work?

    1. Brad Dalton Avatar
      Brad Dalton

      Will you be running Genesis 2.0+?

      The short answer is no they won’t work if you are running Genesis 2.0 and have added HTML 5 support to your child theme.

      The changes only effect the hooks within the loop so you may only need to change 1 or 2 hooks in your functions file.

  10. Thanks for the great tutorial.

    I’m trying to add different opt in forms for posts and pages and adding the opt in form on posts using entry hook is also showing up on pages. Is there a way to exclude pages for entry hooks?

    Thanks,
    Karen

    1. Brad Dalton Avatar
      Brad Dalton

      Yes, Simply add [code]if ( is_single() ) {[/code] or any other conditionals after the function which hooks in your opt in form. You may also need to add an additional curly bracket at the very end of your code.

      You can change the conditional tag if needed. http://codex.wordpress.org/Conditional_Tags

    2. Brad Dalton Avatar
      Brad Dalton

      Karen. If you can provide your code i’ll add it for you and test it.

  11. Hello Brad!! I,m subscribe to newsletter of this site and love each update received. I like very much. I would suggest that you put a search box for ease whenever they wish to take any questions come to this site.

    sorry any mistake, do not speak English, Portuguese and am just using google translator

    Thank you 🙂

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Brenda

      Yes, i do need a search box. Thanks for the feedback.

  12. Arafin Shaon Avatar
    Arafin Shaon

    Hi sir thanks for your awesome tutorial. I’m using genesis html5 child theme ( genesis sample develop) trying to integrate Yoast breadcrumbs but not being able to integrate it properly. Can you help me regarding this issue ?

    Here is the snippet:

    [code]
    //** YOAST BREADCRUMBS
    function yoast_crumbs() {
    if (is_single()) {
    if ( function_exists(‘yoast_breadcrumb’) ) {
    yoast_breadcrumb(”,”);
    }
    }
    }
    add_action(‘genesis_before_loop’, ‘yoast_crumbs’);
    remove_action(‘genesis_before_loop’, ‘genesis_do_breadcrumbs’);
    [/code]

    1. Brad Dalton Avatar
      Brad Dalton

      Did you already install the plugin?

      If you’re using the latest version of WordPress SEO by Yoast, you no longer need to add this code as the breadcrumbs are already included in the plugin.

      1. It still says to add this to your theme’s file, even in the latest version of the plugin.

        Where do we add that in Genesis 2.0?

        1. Brad Dalton Avatar
          Brad Dalton

          I don’t see why you need to add breadcrumbs when they’re already included in Genesis?

          That code is a template tag which you can hook in using a filter, custom function or paste into a template file.

  13. […] Brian Gardner: Genesis HTML5 Loop Hooks Nathan Rice: New Loop Hooks in Genesis 2.0 Carrie Dils: Genesis 2.0 Hook Changes Brad Dalton: New Genesis 2.0 Loop Hooks & How To Use Them […]

  14. […] Brad Dalton Convert Your Genesis Child Theme From XHTML to HTML5 New Genesis 2.0 Loop Hooks & How To Use Them […]

  15. Keith Davis Avatar
    Keith Davis

    Hi Brad
    I’ve seen Carrie’s table and read your previous posts on Gen 2 / HTML5 so I’m slowly getting there.

    Since all the old themes are backward compatible with Genesis 2 (if HTML5 is not activated) I’m wondering if people will update or just switch to one of the new themes – be interesting to see how it plays out.

    I appreciate that the markup is more meaningful to the bots but other than that I’ve not read anything to make me believe that HTML5 websites will have a big advantage in the SEO stakes.
    Are you doing anything which will go a little deeper into SEO benefits – would love to have your thoughts.

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Keith

      I read an article on Yoast recently which you may find interesting.

      I know my traffic has increased recently but its hard to gauge whether that’s from the conversion to HTML 5.

      I think there are SEO benefits but at this stage its still not totally clear to me.

      Thanks or the comment.

      1. Keith Davis Avatar
        Keith Davis

        I only run a couple of my own sites, which I may change over, but I doubt if I will contact clients and ask if they would like an update.

        Once Studiopress have released a few Gen 2 themes and the SEO benefits of HTML are clearer I may bring up the subject with clients.

        1. Brad Dalton Avatar
          Brad Dalton

          Its not difficult to change over. Just a matter of changing the classes.

      2. Mathew Porter Avatar
        Mathew Porter

        Other factors may have increased traffic, especially since Google Penguin 2.0 was released last week.

        1. Brad Dalton Avatar
          Brad Dalton

          Could well be the reason Mathew.

          Thanks for the feedback.

  16. Carrie Dils Avatar
    Carrie Dils

    Keep the good stuff coming! 🙂

    1. Brad Dalton Avatar
      Brad Dalton

      hahaha!

      Like your table Carrie. Great link bait!!

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.