Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created September 8, 2015 16:46
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 generatepress/49b8f215f826ee2b27fc to your computer and use it in GitHub Desktop.
Save generatepress/49b8f215f826ee2b27fc to your computer and use it in GitHub Desktop.
Remove page header default positioning and add the featured image as a background image in the header
add_action( 'wp','generate_remove_page_header' );
function generate_remove_page_header()
{
if ( is_page() )
remove_action('generate_after_header','generate_page_header', 10);
}
add_action( 'wp_head','generate_add_featured_image_background' );
function generate_add_featured_image_background()
{
global $post;
if ( has_post_thumbnail() ) :
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID));
echo '<style>.site-header {background-image: url(' . $image . ' );}';
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment