Gallery Pro is a very popular child theme for the Genesis Framework. One of the frequently asked questions by clients, as well as technical support requests, has been how to add the featured image as a full width hero image to Pages the same way it can be done on Posts. This functionality currently does not exist in Gallery Pro. Below is the code you can use to display a full width hero image on your pages.
Click “View Raw” at the bottom of the code box below. Then browse over to the Gallery Pro theme folder. Open up your functions.php file. Copy/paste the code below at the bottom of the file and save it.
If you are savvy at modifying your code in the dashboard, you can browse to Appearance > Editor. Open the functions.php file, then copy/paste the code at the bottom, then save it.
// Add Featured Hero Image to Pages in Gallery Pro | |
add_action( 'genesis_after_header', 'c8d_gallery_display_featured_image' ); | |
function c8d_gallery_display_featured_image() { | |
if ( ! is_singular( array( 'page' ) ) ) { | |
return; | |
} | |
if( has_post_thumbnail( ) ) { | |
//* Remove the entry header markup (requires HTML5 theme support) | |
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); | |
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); | |
//* Remove the entry title (requires HTML5 theme support) | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
//* Remove the entry meta in the entry header (requires HTML5 theme support) | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
//* Remove the post format image (requires HTML5 theme support) | |
remove_action( 'genesis_entry_header', 'genesis_do_post_format_image', 4 ); | |
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); | |
echo '<div class="hero flexible-widget-area bg bg-scrim text-center" style="background-image: url(' . $image[0] . ');"><div class="wrap">'; | |
genesis_entry_header_markup_open(); | |
genesis_do_post_title(); | |
genesis_post_info(); | |
genesis_entry_header_markup_close(); | |
echo '</div></div>'; | |
} | |
} |