Last active
December 14, 2015 18:49
-
-
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
This file contains hidden or 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
.post-photo { | |
margin-bottom: 35px; | |
display: block; | |
margin: 0 auto 2.4rem; | |
} |
This file contains hidden or 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
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