Skip to content

Instantly share code, notes, and snippets.

@danielortiz
Last active August 29, 2015 14:05
Show Gist options
  • Save danielortiz/a12e2cde778ed08123b3 to your computer and use it in GitHub Desktop.
Save danielortiz/a12e2cde778ed08123b3 to your computer and use it in GitHub Desktop.
displays header_image as header background
if ( ! function_exists( 'prefix_display_header_img' ) ) :
/**
* Displays header_image as header background
* Change 'prefix' to your theme's prefix
* It's ready to be used with _s class '.site-header'
* @see prefix_display_header_img().
*/
function prefix_display_header_img(){
if ( get_header_image() ){
$image = esc_url(get_header_image());
echo '<style type="text/css">.site-header{background-image: url('. $image .');}</style>';
}
}
add_action( 'wp_head', 'prefix_display_header_img' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment