Skip to content

Instantly share code, notes, and snippets.

@brycejacobson
Created August 30, 2013 16:11
Show Gist options
  • Save brycejacobson/6391491 to your computer and use it in GitHub Desktop.
Save brycejacobson/6391491 to your computer and use it in GitHub Desktop.
Genesis 2.0 Loop with hooks
<?php
//* Do NOT include opening php tag
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 **/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment