Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save topleague/f1896399d4ada55e695be0759f41c373 to your computer and use it in GitHub Desktop.
Save topleague/f1896399d4ada55e695be0759f41c373 to your computer and use it in GitHub Desktop.
Featured Hero Image with Entry Title and Subtitle as Overlay
//* Display Featured Hero Image with Entry Title and Subtitle as Overlay
add_action( 'genesis_after_header', 'page_hero_image' );
function page_hero_image() {
// if we are not on a single Post, abort.
if ( !is_singular( 'post' && 'page' ) || is_front_page()) {
return;
}
// set $image to URL of featured image. If featured image is not present, set it to post-image.jpg in child theme's images directory.
if ( has_post_thumbnail() ) {
$image = genesis_get_image( 'format=url&size=post-image' );
} else {
$image = get_stylesheet_directory_uri() . '/images/post-image.jpg';
} ?>
<!-- <div class="post-hero" style="background: #ffd700;"> -->
<div class="post-hero" style="background-image: linear-gradient(to right, white, transparent), url('<?php echo $image; ?>')">
<div class="wrap">
<?php genesis_post_info(); ?>
<?php genesis_do_post_title(); ?>
<?php content_excerpt(); ?>
</div>
</div>
<?php
// Remove entry title
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info' );
remove_action( 'genesis_entry_header', 'content_excerpt', 10 );
}
//* Remove the entry meta in the entry header (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment