Created
September 21, 2014 07:36
-
-
Save jamiemitchell/57c59e0baf1e6203a1fd to your computer and use it in GitHub Desktop.
Add a second custom loop for CPT to a front page template in Genesis that won't effect the defailt loop.
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 | |
//* Add markup for homepage portfolio | |
add_action( 'genesis_after_header', 'minimum_home_portfolio', 20 ); | |
function minimum_home_portfolio() { | |
printf( '<div %s>', genesis_attr( 'home-portfolio' ) ); | |
genesis_structural_wrap( 'home-portfolio' ); | |
$args = array( | |
'post_type' => 'portfolio', | |
'order' => 'DESC', | |
'posts_per_page' => 4 | |
); | |
$loop = new WP_Query( $args ); | |
if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post(); | |
do_action( 'genesis_before_entry' ); | |
printf( '<article %s>', genesis_attr( 'entry' ) ); | |
do_action( 'genesis_before_entry_content' ); | |
printf( '<div %s>', genesis_attr( 'entry-content' ) ); | |
if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) { | |
printf( '<div class="portfolio-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); | |
} | |
echo '</div>'; //** end .entry-content | |
do_action( 'genesis_after_entry_content' ); | |
echo '<h1 itemprop="headline" class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h1>'; | |
echo '</article>'; | |
do_action( 'genesis_after_entry' ); | |
endwhile; endif; wp_reset_postdata(); | |
genesis_structural_wrap( 'home-portfolio', 'close' ); | |
echo '</div>'; //* end .home-portfolio | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment