-
-
Save billerickson/047f8a038da53d300425974aab6da8fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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