Add WordPress Custom Header Image & Custom Background


In function.php files, use this code:

/* Add Custom Background */
add_custom_background();

/**
* Add support for WordPress custom header image.  On that note, this is horrible and messy.  Expect a
* rewrite of this entire code into something more beautiful in future versions.
*/
add_custom_image_header( '__return_false', '__return_false' );
define( 'NO_HEADER_TEXT', true );
define( 'HEADER_IMAGE', '' ); // By leaving empty, we allow for random image rotation.
define( 'HEADER_IMAGE_WIDTH', 960 );
define( 'HEADER_IMAGE_HEIGHT', 400 );

// Turn on random header image rotation by default.
add_theme_support( 'custom-header', array( 'random-default' => true ) );

register_default_headers( array(
'banner1' => array(
'url' => '%s/images/headers/banner1.jpg',
'thumbnail_url' => '%s/images/headers/banner1-thumb.jpg',
/* translators: header image description */
'description' => __( 'banner1', 'simplejoss' )
),
'banner2' => array(
'url' => '%s/images/headers/banner2.jpg',
'thumbnail_url' => '%s/images/headers/banner2-thumb.jpg',
/* translators: header image description */
'description' => __( 'banner2', 'simplejoss' )
)
) );

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: