Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Created October 21, 2013 01:25
Show Gist options
  • Save jamiemitchell/7077407 to your computer and use it in GitHub Desktop.
Save jamiemitchell/7077407 to your computer and use it in GitHub Desktop.
Custom Genesis home page with 2 widget areas and loop to pull in portfolio CPT.
<?php
/* Add the homepage widgets and projects
------------------------------------------------------------ */
add_action( 'genesis_loop', 'jmd_homepage_widgets' );
function jmd_homepage_widgets() {
genesis_widget_area( 'home-top', array(
'before' => '<div class="home-top"><div class="wrap">',
'after' => '</div></div>',
) );
echo '<div class="home-projects"><div class="wrap">';
$args = array(
'post_type' => 'portfolio',
'order' => 'DESC',
'posts_per_page' => 2
);
$tips = new WP_Query( $args );
if( $tips->have_posts() ):
while ( $tips->have_posts() ) : $tips->the_post();
$classes = 0 == $tips->current_post || 0 == $tips->current_post % 2 ? 'entry one-half first' : 'entry one-half';
echo '<div class="' . $classes . '">';
echo '<a class="quicklink" href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'full');
echo '<h4>' . get_the_title() . '</h4>';
echo '</a>';
echo '</div>';
endwhile;
endif;
wp_reset_postdata();
echo '</div></div>';
genesis_widget_area( 'home-bottom', array(
'before' => '<div class="home-bottom"><div class="wrap">',
'after' => '</div></div>',
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment