Skip to content

Instantly share code, notes, and snippets.

@DMSpeed
Last active August 29, 2015 14:10
Show Gist options
  • Save DMSpeed/75f232ee333ee7609545 to your computer and use it in GitHub Desktop.
Save DMSpeed/75f232ee333ee7609545 to your computer and use it in GitHub Desktop.
/** Add post image above post title */
add_action( 'genesis_before_post_title', 'decor_post_image' );
function decor_post_image() {
if ( is_page() ) return;
else
if( in_array( 'teaser', get_post_class() ) && $image = genesis_get_image( 'format=url&size=grid-image' ))
{printf( '<a href="%s" rel="bookmark" class="post-photo"><span class="grid-date">%s</span><img src="%s" alt="%s" /></a>', get_permalink(), do_shortcode( '<em>[post_date format="j"]</em>[post_date format="F Y"]' ), $image, the_title_attribute( 'echo=0' ) );
}
else
if( in_array( 'feature', get_post_class() ) && $image = genesis_get_image( 'format=url&size=post-image' ))
{printf( '<a href="%s" rel="bookmark" class="post-photo"><span class="post-date">%s</span><img src="%s" alt="%s" /></a>', get_permalink(), do_shortcode( '<em>[post_date format="j"]</em>[post_date format="F Y"]' ), $image, the_title_attribute( 'echo=0' ) );
}
}
@DMSpeed
Copy link
Author

DMSpeed commented Nov 25, 2014

This creates a grid loop on the homepage of a site using the Decor theme, and shows the featured image above the post title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment