Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active December 14, 2015 18:49
Show Gist options
  • Save braddalton/5132362 to your computer and use it in GitHub Desktop.
Save braddalton/5132362 to your computer and use it in GitHub Desktop.
This PHP code displays an image before your post title on single posts and archive pages on themes running the old XHTML markup
.post-photo {
margin-bottom: 35px;
display: block;
margin: 0 auto 2.4rem;
}
add_action( 'genesis_before_post', 'wpsites_before_post_image', 5 );
function wpsites_before_post_image() {
if ( is_page() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
/**
* @author Brad Dalton - WP Sites
* @works for themes still using XHTML markup
* @examples http://wpsites.net/web-design/add-remove-image-above-post-title/
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment