Last active
June 26, 2019 14:34
-
-
Save justadityaraj/22d11a0827baf69704f5e4b63a586de2 to your computer and use it in GitHub Desktop.
Add Featured Image at top of Single Post/Page in Genesis framework
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
<?php //<= remove this | |
// Add featured image on single post | |
add_action( 'genesis_entry_content', 'themeprefix_featured_image', 1 ); | |
function themeprefix_featured_image() { | |
$add_single_image = get_theme_mod( 'themeprefix_single_image_setting', true ); //sets the customizer setting to a variable | |
$image = genesis_get_image( array( // more options here -> genesis/lib/functions/image.php | |
'format' => 'html', | |
'size' => 'large',// add in your image size large, medium or thumbnail - custom size => array(300, 450, true), | |
'context' => '', | |
'attr' => array ( 'class' => 'aligncenter' ), // set a default WP image class | |
) ); | |
if ( is_singular() && ( true === $add_single_image ) ) { | |
if ( $image ) { | |
printf( '<div class="featured-image-class">%s</div>', $image ); // wraps the featured image in a div with css class you can control | |
} | |
} | |
} | |
// www.wprumors.com - adityaraj.de |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment