Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active October 24, 2018 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/047f8a038da53d300425974aab6da8fd to your computer and use it in GitHub Desktop.
Save billerickson/047f8a038da53d300425974aab6da8fd to your computer and use it in GitHub Desktop.
<?php
/**
* Loop
*
* @package EAGenesisChild
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
**/
/**
* Use Archive Loop
*
*/
function ea_use_archive_loop() {
if( ! is_singular() ) {
add_action( 'genesis_loop', 'ea_archive_loop' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
}
}
add_action( 'genesis_setup', 'ea_use_archive_loop', 20 );
/**
* Archive Loop
* Uses template partials
*/
function ea_archive_loop() {
if ( have_posts() ) {
do_action( 'genesis_before_while' );
while ( have_posts() ) {
the_post();
do_action( 'genesis_before_entry' );
// Template part
$partial = apply_filters( 'ea_loop_partial', 'archive' );
$context = apply_filters( 'ea_loop_partial_context', is_search() ? 'search' : get_post_type() );
get_template_part( 'partials/' . $partial, $context );
do_action( 'genesis_after_entry' );
}
do_action( 'genesis_after_endwhile' );
} else {
do_action( 'genesis_loop_else' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment