Skip to content

Instantly share code, notes, and snippets.

@cre8tivediva
Created June 28, 2018 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cre8tivediva/c549edef2a62dddad4b4a660fd25f80f to your computer and use it in GitHub Desktop.
Save cre8tivediva/c549edef2a62dddad4b4a660fd25f80f to your computer and use it in GitHub Desktop.
How to Add Hero Image to Pages in Gallery Pro Child Theme
// 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>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment