New Loop Hooks in Genesis 2.0

If you haven’t heard, Genesis 2.0 is coming soon (you can run Genesis beta by using this plugin). And with it comes the ability to make your site output HTML5 markup and microdata, which put a new emphasis on semantics in the way we mark up out content.

With this in mind, it became clear to us that our old loop hooks just didn’t pass the smell test. “post” simply does not accurately describe the types of content you can manage with WordPress. For instance, pages. Or worse, the infinite possible content types you can create and manage with Custom Post Types.

Using the genesis_before_post_content hook to insert something before the page content makes very little sense.

So we decided to update the Genesis loop function to reference the “entry” instead. We also updated our tag classes to follow this same pattern: entry, entry-header, entry-title, entry-meta, entry-content, entry-footer … you get the idea.

Note: if you’re using Genesis without HTML5 activated, all the old hooks and markup work as before. Genesis 2.0 is 100% backward compatible.

If HTML5 is not active, it uses the legacy loop (with all the old hooks and markup).

So, if you want to insert something after a post, page, or custom post type, you need to use the genesis_after_entry hook.

Pretty simple.

But the same goes for the things that you would want to unhook.

If you want to remove something from executing, you need to remove it from the new hook, rather than the old one. Here’s a list of the default entry element actions:

	add_action( 'genesis_entry_header', 'genesis_do_post_format_image', 4 );
	add_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
	add_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
	add_action( 'genesis_entry_header', 'genesis_do_post_title' );
	add_action( 'genesis_entry_header', 'genesis_post_info', 12 );

	add_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
	add_action( 'genesis_entry_content', 'genesis_do_post_content' );
	add_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 );
	add_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );

	add_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
	add_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
	add_action( 'genesis_entry_footer', 'genesis_post_meta' );

	add_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
	add_action( 'genesis_after_entry', 'genesis_adjacent_entry_nav' );
	add_action( 'genesis_after_entry', 'genesis_get_comments_template' );

So there you go! New semantic HTML5 hooks in Genesis 2.0. Enjoy!

10 Replies to “New Loop Hooks in Genesis 2.0”

  1. Can’t wait! I’ll hit my portfolio site AS SOON AS it comes out- needs revised thoroughly! 🙂

  2. Thanks for the new HTML5 hooks list. Gonna experiment them. Your blog is rocking Genesis 2.0, nice to see that!

  3. Thanks for the details. I noticed the update on Studiopress blog and followed several conversations on Twitter. It is nice to have these hooks. As long as these hooks are used, should previous custom loops and queries still work?

    1. Not sure exactly what you mean here. These new hooks only activate if you turn on HTML5. Otherwise, all the old hooks still work just fine.

  4. 2.0 looks great, but how long will backward compatibility last? A year or two from now will I have to upgrade all client sites to use the new hooks and new CSS selectors?

    1. At some point, not sure when, we’ll remove the backward compatibility and only offer auto-updates to people who are running a theme that supports HTML5. It’s just the way it has to be … we can’t litter the Genesis source code with conditionals for infinite backward compatibility forever. But before we do that, we’ll update all the StudioPress themes to work with HTML5, and will probably maintain the 2.0.x branch for a year or so with security updates, etc., so you’re not caught with an insecure version of Genesis.

  5. […] Ver el post original de Nathan Rice […]

  6. Great info, thank you very much for the write up. I am going through the 2.0 making notes of changes, and your list just came in real handy. Much appreciated!

  7. Could you, please, tell how you put this LET’S CONNECT?

  8. […] need not to worry about change in naming conventions of hooks,Here is an article published on that issue.This is what they […]

Comments are closed.