WordPress custom header image API gives blog administrator the ability to control and change the header design (image and font color).
This functionality is very easy to add and use, and upgrades the theme usability significantly.
The interface is added to the Appearance menu.

And looks like this:

The code bits are pretty simple:
Assumin the header part lookis like this:
[cc lang='php']
[/cc]
We need to add 3 different secions to out function.php
- Default values definition – text color, background image, image width, image height
- The API callback function – functions that alter the header css upon activation. There are two such functions:
- The function set as header_callback is called when displaying a specific blog page. It is activated by the action_hook wp_head
- The function set as admin_header_callback is called when displaying administration panels
- Callback registration
The definitions code looks like this:
[cc lang='php']
// Set some default values
define('HEADER_TEXTCOLOR', 'fff'); // Default text color
define('HEADER_IMAGE', '%s/default.jpg'); // %s is theme dir uri, set a default image
define('HEADER_IMAGE_WIDTH', 500); // Default image width is actually the div's height
define('HEADER_IMAGE_HEIGHT', 150); // Same for height
?>
[/cc]
Once we’ve set the default values we can add the callback functions:
[cc lang='php']
function header_style() {
// You can change these selectors to match your theme
?>
}
// This function is not relevant unless you want your admin
// header to be changed as well... You can leave it empty
function admin_header_style() {
// This function styles the admin page
?>
}
?>
[/cc]
Now we just need to register the callbacks:
[cc lang="php"]
add_custom_image_header('header_style', 'admin_header_style');
?>
[/cc]
Note that this API is activated by calling wp_head() so if your function does not have that function call in header.php you should add it.
In oredr to add wp_head to your header you need to add the following line just before the body tab:
[cc lang="php"][/cc]

