I am currently building a site using a child theme for the first time.
Basically, I have a flash banner the client has already had made, and want to replace the twentyten image banner with the flash. I know how to do this by editing the header.php (I think!) but was wondering if there was a better way to do it – using function.php in my child theme perhaps?
It would be nice if the client could update the theme themselves and not worry about the header being changed back.
Thanks for any contributions.
A child theme is definitely the way to go for the reason you outlined: upgradability. To start with, here is the documentation for creating child themes: http://codex.wordpress.org/Child_Themes
You’ll want to create the child theme directory and edit the
style.css
file as described in the Child Theme documentation link above. After that, simply copy theheader.php
file from thetwentyten
directory into the directory and modify it to include the Flash element you have. By copying theheader.php
to a child theme, it will override the parent theme’s version and be preserved after an update to the parent theme.This is the block you want to edit, as it creates the header image:
I would just delete that entire PHP block, and replace it with the
<object>
code for your flash element. You’ll want to make sure the flash element is exactly 940 pixels across, though, or it might look strange/break the design.The header image PHP block is located on line 68 of my
header.php
(in the WordPress 3.1 twentyten theme), and it’s located directly below the following:Note that this isn’t foolproof. If the twentyten theme gets updated in the future and contains changes you would like to have in the child theme they won’t appear here. However, to add a hook which replaces the image header with a Flash one would require modifying the base theme’s header.php… a bit of a catch 22. In practice this shouldn’t be much of an issue, though. It’s also the best way in WordPress to handle this sort of thing.
For reference, here are the changes to the file on its Trac page.