Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active August 29, 2015 14:06
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 billerickson/cee137e430192972cbd8 to your computer and use it in GitHub Desktop.
Save billerickson/cee137e430192972cbd8 to your computer and use it in GitHub Desktop.
<?php
/**
* Site Header Background
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/background-image-site-header/
*/
function be_site_header_background( $attributes ) {
$image = false;
if( is_page() )
$image = get_post_meta( get_the_ID(), 'be_page_header', true );
if( ! $image )
return $output;
$image = wp_get_attachment_image_src( $image, 'full' );
$attributes['class'] .= ' has-image';
$attributes['style'] = 'background-image: url(' . $image[0] . ');';
return $attributes;
}
add_filter( 'genesis_attr_site-header', 'be_site_header_background' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment