Friday, June 10, 2011

WordPress! - change the header image in your child theme of twentyten

I've finally arrived at the WordPress users' orbit. With it came all the trials and retributions of mod'ing other people's templates into something that I want the site to actually look like. TwentyTen is the now standard basic template that ships with the default WP install and while making a child theme off of it turned out to be remarkably easy getting it to look like something else is not so much.

Here's a solution that turned out to be clean and simple to provide your own header image instead of the one of several that come with 2010.

Put the following code into your child theme's functions.php file:



$siteurl=get_option('siteurl');
define( 'HEADER_IMAGE', $siteurl.'/wp-content/themes/mychildtheme/images/header.png' );
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 965 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 160 ) );


First line gets us the url of the site and the rest of the values on the second line is the way to get to the subdirectory containing your child theme's header image thus building the image URI without hard-coding anything in.

The remaining two lines override the header image size for the 2010 template to reflect your header's dimensions.

All Done.

No comments:

Post a Comment