Skip to content

Instantly share code, notes, and snippets.

@Magnacarter
Created January 23, 2015 18:50
Show Gist options
  • Save Magnacarter/544430042ec7896cb2b6 to your computer and use it in GitHub Desktop.
Save Magnacarter/544430042ec7896cb2b6 to your computer and use it in GitHub Desktop.
/**
* Remove the Genesis custom loop and add custom template
*
* Added a counter to my WordPress loop to avoid having to use the Genesis Grid Loop
*
* @action genesis_loop
*
* @return void
*/
function rjs_portfolio_loop() {
$args = array(
'post_type' => 'portfolio',
);
$portfolio = new WP_Query( $args );
if ( $portfolio->have_posts() ) :
?>
<div class="projects">
<?php $i = 0 ?>
<?php while ( $portfolio->have_posts() ) : $portfolio->the_post(); $i++ ?>
<div class="project one-half<?php echo ( 0 !== $i % 2 ) ? ' first' : null ?>">
<div class="project_image">
<img src="<?php the_field('project_image') ?>" height="400" width="400" />
</div>
</div>
<?php endwhile; ?>
</div>
<?php
endif;
wp_reset_postdata();
}
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'rjs_portfolio_loop');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment