Created
December 25, 2014 06:41
-
-
Save anonymous/6c81a11e6329f4a397b1 to your computer and use it in GitHub Desktop.
Add featured image to single post with genesis get image HTML and URL for lightboxes
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
add_action( 'genesis_entry_content', 'os_show_featured_image_single_posts', 9 ); | |
function os_show_featured_image_single_posts() { | |
global $post; | |
if ( ! is_singular( 'post' ) ) { | |
return; | |
} | |
// Get the featured image HTML | |
$image_html_args = array( | |
'size' => 'post-image', | |
'attr' => array( | |
'class' => 'aligncenter featured-image size-full wp-image-' . $post->ID .'', | |
), | |
); | |
$image_html = genesis_get_image( $image_html_args ); | |
// Get the featured image URL for the lightbox a href only | |
$image_url_args = array( | |
'format' => 'url', | |
); | |
$image_url = genesis_get_image( $image_url_args ); | |
// Display the Image using both calls above | |
echo '<a rel="lightbox" href="' . $image_url . '">'. $image_html .'</a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment