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 Schema.org 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.
Here’s the new standard loop in Genesis 2.0
function genesis_standard_loop() {
//** Use old loop hook structure if < HTML5
if ( ! genesis_html5() ) {
genesis_legacy_loop();
return;
}
global $loop_counter;
$loop_counter = 0;
if ( have_posts() ) : while ( have_posts() ) : the_post();
do_action( 'genesis_before_entry' );
printf( '<article %s>', genesis_attr( 'entry' ) );
do_action( 'genesis_entry_header' );
do_action( 'genesis_before_entry_content' );
printf( '<div %s>', genesis_attr( 'entry-content' ) );
do_action( 'genesis_entry_content' );
echo '</div>'; //** end .entry-content
do_action( 'genesis_after_entry_content' );
do_action( 'genesis_entry_footer' );
echo '</article>';
do_action( 'genesis_after_entry' );
$loop_counter++;
endwhile; /** end of one post **/
do_action( 'genesis_after_endwhile' );
else : /** if no posts exist **/
do_action( 'genesis_loop_else' );
endif; /** end loop **/
}
If HTML5 is not active, it uses the legacy loop (with all the old hooks and markup).
So, as you can see, 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', 5 ); 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_content', 'genesis_do_post_image' ); add_action( 'genesis_entry_content', 'genesis_do_post_content' ); add_action( 'genesis_entry_content', 'genesis_do_post_permalink' ); add_action( 'genesis_entry_content', 'genesis_do_post_content_nav' ); add_action( 'genesis_entry_header', 'genesis_post_info' ); 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' ); add_action( 'genesis_loop_else', 'genesis_do_noposts' ); add_action( 'genesis_after_endwhile', 'genesis_posts_nav' );
So there you go! New semantic HTML5 hooks in Genesis 2.0. Enjoy!
It’s been talked about time and 