With the various theme hooks and theme filters, now it’s easier then ever to change the Thematic header with your own logo or custom banner design.
Until now you had to either change the header.php file in Thematic (something not really recommended) or use rather ugly CSS tricks to hide the existing content and use your logo or banner as a background for the #header or #branding div.
The end result will be a Child Theme Options page that will allow us to select if we want to use the default header or upload a header image:

Child Theme Options Page - You now have the posibility to upload your header image from Wordpress
We’ll start by creating a Child Theme. If you are already using one of the Thematic Child Themes then you can move to the next step, modifying the functions.php file.
The code for this tutorial was created by my colleague Gabriel. He always helps me with custom programing for Wordpress
!
This functions.php file will consist of two parts: adding the Child Theme Options page to Wordpress and replacing the default header with your own logo or banner image.
Open functions.php and add the following code:
<?php
// ---------- "Child Theme Options" menu STARTS HERE
add_action('admin_menu' , 'childtheme_add_admin');
function childtheme_add_admin() {
add_submenu_page('themes.php', 'Child Theme Options', 'Child Theme Options', 'edit_themes', basename(__FILE__), 'childtheme_admin');
}
function childtheme_admin() {
$child_theme_image = get_option('child_theme_image');
$enabled = get_option('child_theme_logo_enabled');
if ($_POST['options-submit']){
$enabled = htmlspecialchars($_POST['enabled']);
update_option('child_theme_logo_enabled', $enabled);
$file_name = $_FILES['logo_image']['name'];
$temp_file = $_FILES['logo_image']['tmp_name'];
$file_type = $_FILES['logo_image']['type'];
if($file_type=="image/gif" || $file_type=="image/jpeg" || $file_type=="image/pjpeg" || $file_type=="image/png"){
$fd = fopen($temp_file,’rb’);
$file_content=file_get_contents($temp_file);
fclose($fd);
$wud = wp_upload_dir();
if (file_exists($wud[path].'/'.strtolower($file_name))){
unlink ($wud[path].'/'.strtolower($file_name));
}
$upload = wp_upload_bits( $file_name, '', $file_content);
// echo $upload['error'];
$child_theme_image = $wud[url].'/'.strtolower($file_name);
update_option('child_theme_image', $child_theme_image);
}
?>
<div class="updated"><p>Your new options have been successfully saved.</p></div>
<?php
}
if($enabled) $checked='checked="checked"';
?>
<div class="wrap">
<div id="icon-themes" class="icon32"></div>
<h2>Child Theme Options</h2>
<form name="theform" method="post" enctype="multipart/form-data" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);?>">
<table class="form-table">
<tr>
<td width="200">Use logo image instead of blog title and description:</td>
<td><input type="checkbox" name="enabled" value="1" <?php echo $checked; ?>/></td>
</tr>
<tr>
<td>Current image:</td>
<td><img src="<?php echo $child_theme_image; ?>" /></td>
</tr>
<tr>
<td>Logo image to use (gif/jpeg/png):</td>
<td><input type="file" name="logo_image"><br />(you must have writing permissions for your uploads directory)</td>
</tr>
</table>
<input type="hidden" name="options-submit" value="1" />
<p class="submit"><input type="submit" name="submit" value="Save Options" /></p>
</form>
</div>
<?php
}
// ---------- "Child Theme Options" menu ENDS HERE
// ---------- Adding the logo image to the header STARTS HERE
if(get_option('child_theme_logo_enabled')){
function remove_thematic_blogtitle() {
remove_action('thematic_header','thematic_blogtitle',3);
}
add_action('init','remove_thematic_blogtitle');
function remove_thematic_blogdescription() {
remove_action('thematic_header','thematic_blogdescription',5);
}
add_action('init','remove_thematic_blogdescription');
function thematic_logo_image() {
echo '<div id="logo-image"><a href="'.get_option('home').'"><img src="'.get_option('child_theme_image').'" /></a></div>';
}
add_action('thematic_header','thematic_logo_image',4);
}
// ---------- Adding the logo image to the header ENDS HERE
?>
This source code works on all Thematic 0.9 Child Themes. If you’re using an older version of Thematic, chances are this won’t work.
Save and go into your Wordpress admin panel under “Appearance -> Child Theme Options”. If every thing worked out ok you should have a similar admin panel as the one in the picture on top of the page.
As a side note there’s already in the works a plugin for Wordpress that will make modifying Thematic a breeze so keep an eye out for great new things coming your way!







112 Comments
@Amine you are welcome. The images not showing up could be a database issue if you pull your images from within there.
Good luck.
I downloaded another theme (pixel) and I was able to upload the header without any problems….:) Not sure why the thematic child theme wont let me…
dammmm it. my buddy from canada just figured it out for me and its something very stupid…lol
this is his message:
ou’re working with a linux web server for your site, so the file names are CASE sensitive, i.e. LOGO2.jpg and logo2.jpg are not same.
Either you can rename the file to match what it is being called or change the way it is being called.
. if you go to any page on your site and right click, IE or firefox will give you this menu item ‘view source’. Once you select that it’ll bring up a page in html, here you can search for that file ‘logo2.jpg’ and you can get more details.
thanks for everyone for trying. its truly appreciated and thanks for the thematic and child theme. its truly appreciated. as someone famous said. there is no such thing as genius, its all about persistence……:)
@Amine on a Linux server you have to be careful naming files. Always best to use all lower case alphabets or numbers, nothing else.
Good Luck with your project @Amine. Is your site working now?
yes, its awesome
http://www.isearchBankhomes.com
i still have lots of work to do to finish it up…:)
Very well done site @Amine. What images were you talking about. All image links are working fine.
@ed thanks for the compliment. Feel free to give any feedback on my website. It was the Banner that wouldn’t show up because of the case senstivie issue….got it working finally…:)
I am glad it all worked out for you in the end. Persistence pays off big time.
Any guidance on what size the banner image should be?
Just look for the size of the banner in the HTML and make sure the image size is the same or lesser than it.
Does it matter if you stick this PHP code at the bottom of your functions.php in Thematic? Or does it need to be somewhere specific?
Thanks so much,
k.n.
This is thought to be uses inside the functions.php file of a child theme. This way you won’t make any modifications to Thematic and future updates to the framework will be really simple to do.
@Kyndra that should be fine.
Hi, I added the code to my child theme and uploaded a test image and it went up without a problem. I then switched it out with the same image (but with text added), and it now shows this:
Warning: fopen(/tmp/php2jY71f) [function.fopen]: failed to open stream: Success in /home/reddwarf/public_html/wp-content/themes/thematic/functions.php on line 113
Warning: fclose(): supplied argument is not a valid stream resource in /home/reddwarf/public_html/wp-content/themes/thematic/functions.php on line 115
and the header is no longer appearing. Please forgive me if the answer is obvious, I’m clueless with this stuff.
just as an addition – the original test banner still works. What am I doing wrong with the new image? It’s the same file size, width and height, file type, etc.
The text on the image looks to be the issue here. Does it work well without the text? Have you tried to overlay the text over the image or is the text part of the image itself?
I overlayed the text on the image via photoshop. The original image still works, but no other image seems to work, with or without text.
I’m going to keep fiddling to see if I can discover what makes this image different from the others… any suggestions? You may want to try sending me an image that works for you to see if it works for me as well.
Is it possible I added the code incorrectly and that’s the source of these inconsistencies?
Have you tried to superimpose your text on your image in Photoshop and save it to your desktop? Then go ahead and upload it to your theme’s folder? I have done that at times to make text over images work.
I added the code to my functions.php in my child theme and now I am getting this error:
Warning: Cannot modify header information – headers already sent by (output started at /home/hypr/public_html/blog/wp-content/themes/johng/functions.php:104) in /home/hypr/public_html/blog/wp-includes/pluggable.php on line 868
Not sure what I need to do to fix this. Any thoughts?
This probably means you have spaces after the last php closing tag in functions.php.
Check for that and let me know if it fixed it!
Yeah, I think it was just a syntax error. I re-pasted the code along with some of my other functions and everything started working just fine. Thanks very much for the input!
Am glad it worked out for you. Nice place to ask questions here.
Could be a syntax error. I would check for mistakes there first.
@Brenda what server are you on?
One Trackback
[...] Add a Header Image to Thematic the Easy Way [...]