Create a hook in functions.php
//ADD COVER TO ONLY SUB PAGES
function add_background_cover(){
if ( !is_front_page() ) {
include('inc/cover.php');
}
}
add_action('genesis_after_header', 'add_background_cover');
Create a file inc/cover.php and place the following snippet in it. Don’t forget to replace the ACF slug in cover_subtitle() function!
<?php
//Cover Background
function cover_background() {
function cover_subtitle() {
if( get_field('........') ){ the_field('........') }
else{ echo 'Hello World!'; }
}
$bgImage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
if( has_post_thumbnail() ){ ?>
<section class="cover" style="background-image: url('<?php echo $bgImage[0]; ?>'); ">
<h1 class="entry-title" itemprop="headline"><?php the_title(); ?></h1>
<p><?php cover_subtitle(); ?></p>
</section>
<?php }
else{ ?>
<section class="cover" style="background-image: url(..............); ">
<h1 class="entry-title" itemprop="headline"><?php the_title(); ?></h1>
<p><?php cover_subtitle(); ?></p>
</section>
<?php
}
}
cover_background();
?>
CSS
.cover {
height: 280px;
padding-top: 60px;
}