Last active
November 9, 2017 09:51
-
-
Save topleague/ff4905a975643f5a72773020b16db6ac to your computer and use it in GitHub Desktop.
How to Overlay Entry Title and Excerpts on Featured Image in Genesis
This file contains hidden or 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 Excerpt support to Pages in Genesis | |
add_post_type_support( 'page', 'excerpt' ); | |
//* Display Page Title and Page Excerpt (as Subtitle) after Header | |
add_action( 'genesis_header', 'susanta_remove_page_title'); | |
function susanta_remove_page_title () { | |
if ( is_singular( 'post' && 'page' ) && has_excerpt() && !is_front_page()) { | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
add_action( 'genesis_after_header', 'susanta_after_header_content' ); | |
function susanta_after_header_content() { | |
// 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-image: linear-gradient(to right, white, transparent), url('<?php echo $image; ?>')"> | |
<div class="wrap"> | |
<?php echo '<p class="post-info">' . genesis_post_info() . '</p>'; ?> | |
<?php echo '<h1 itemprop="headline" class="page-title">' . get_the_title() . '</h1>'; ?> | |
<?php echo '<p class="page-excerpt">' . get_the_excerpt() . '</p>'; ?> | |
</div> | |
</div> | |
<?php | |
} | |
} | |
// Remove entry meta from header | |
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