Last active
August 29, 2015 14:05
-
-
Save danielortiz/a12e2cde778ed08123b3 to your computer and use it in GitHub Desktop.
displays header_image as header background
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
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