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!







144 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?
I’m using Buddymatic with the basic Buddymatic child theme. I thought I’d give this a shot.
I was really encouraged when, after pasting the above code into my theme’s function.php, I got the options page on my backend and it appeared to work flawlessly. That is, it let me upload my custom image and it appeared on the option page. Except that it didn’t actually change my site.
I’m thinking maybe that there’s something simple that needs to be changed to make this work. Any ideas?
Nevermind! Got it going!!! I was pasting it into my functions.php incorrectly!
Beautiful! Thanks!
Be careful about how and where you enter code in the functions.php file.
Would it be possible to have rotating header images? Like for instance having a folder of header images, one of which is randomly chosen every time the page is loaded?
Thanks
You might need to do some custom coding to the CSS in order to achieve that @BM.
prior to the commencement, let me say THX for this! I’ve implemented the code in my Thematic child’s functions.php. It works fiine and lets me change the header image and fade out blog’s title and description.
Just one problem:
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
I’ve checked the code several times: no unwary spaces, nothing that a. explains the error message or b. explains why everything’s working fine although I receive that message. Any idea?
Those are warnings and not error messages. Your server should have not displayed those… I think…
Looks like a parsing error encountered by your server. Did you check the line it says the error was on?
Here’s the exact message:
Warning: fopen(/tmp/phpbnhsuA) [function.fopen]: failed to open stream: Success in /home/web160/klem08/ftproot/www.kunstgriff-pix.org/wordpress/wp-content/themes/simply_sankt_pauli/functions.php on line 50
Warning: fclose(): supplied argument is not a valid stream resource in /home/web160/klem08/ftproot/www.kunstgriff-pix.org/wordpress/wp-content/themes/simply_sankt_pauli/functions.php on line 52
Your code starts @ line 28. There’s some code for a home link in the menu and a custom footer in those first lines.
After having removed the first lines (just this code is left) it says line 24 and 26.
Looks like an opening and closing script error there. Need to see the entire code to figure it out.
Would be too long for a comment. You’ll find the complete child’s functions.php code here. THX 4 your support.
I think this is more a php thing then anything else.
Have a look at the php fopen function:
http://webcache.googleusercontent.com/search?q=cache:l92Jmg-abbcJ:php.net/manual/en/function.fopen.php+Warning:+fopen%28/tmp/phpbnhsuA%29+function.fopen:+failed+to+open+stream:&cd=3&hl=en&ct=clnk&client=firefox-a
That is what I think too. Looks like a php error.
Awesome thank you!
Help. I am very new to wordpress customization. I have successfully installed a child theme of thematic but am running into difficulty when adding this php code to functions.php. I save it and it says “file updated successfully” but then I don’t have a child theme options tab underneath appearances. Does the latest version of thematic support this, or am I missing a crucial step. It is for this site http://www.tybeenorthbeachrentals.com
any and all feedback is greatly appreciated!
Thanks!
I edited functions.php outside of wordpress and uploaded it via ftp. This solved the problem! Thanks for the great code!!
You should be able to edit it on server backend also. No need for FTP to do something like that.
what is your opinion on how the loss of the header tags might affect SEO?
i’ve been trying to tweak this so that you can have the image and the headers. it is easy to tweak the code such that the image is the background image for the h1 tag and text-indent away the link, but i find this only works when i know the specific dimensions, in which case why do i need an options panel.
except that i want the options panel if i am developing a theme for public consumption… and i like to use timthumb so that i can keep a lid on the max size of the logo image.
def havent figured this one out yet, but it is a great addition to an options panel!
You can have text links over the image. Use style.css to add it on.
Have to some more testing with WP 3.0 to make sure it is compatible.
So I added the code and the admin section came up. When I tried to upload an image I got this message:
“Warning: fopen(/tmp/php4zGvst) [function.fopen]: failed to open stream: Success in /home/content/88/6358288/html/wp-content/themes/thematic/functions.php on line 119
Warning: fclose(): supplied argument is not a valid stream resource in /home/content/88/6358288/html/wp-content/themes/thematic/functions.php on line 121
Looks like a scripting error. Check the code.
Anything specific I should be looking for. Is it something in the function.php file or somewhere else?
Try checking it at php.net to start off. Who is your host?
Hey Felton.
That error appears on certain hosts and to be honest I haven’t figured it out so far. Some php configurations work without any issues while others don’t.
Try and have a look at this:
http://webcache.googleusercontent.com/search?q=cache:l92Jmg-abbcJ:php.net/manual/en/function.fopen.php+Warning:+fopen%28/tmp/phpbnhsuA%29+function.fopen:+failed+to+open+stream:&cd=3&hl=en&ct=clnk&client=firefox-a
It’s the fopen function over at php.net. Maybe it can help you.
After attempting to upload my image I’m getting a similar message. Errors are on different lines though:
Warning: fopen(/tmp/phprpILcL) [function.fopen]: failed to open stream: Success in /home/alidabar/public_html/wp-content/themes/thematics-child/functions.php on line 24
Warning: fclose(): supplied argument is not a valid stream resource in /home/alidabar/public_html/wp-content/themes/thematics-child/functions.php on line 26
Concerning the first line, line 24, the copy & paste code uses the ‘rb’ mode as follows:
$fd = fopen($temp_file,’rb’);
line 26 looks like this:
fclose($fd);
Chris, I read the PHP manual you linked to and it looks like it might be a server issue but my other concern is that it might be a operating system issue? I am working on a Mac. Could it be this simple/dumb?
I’ll try editing it in plain text (which is what I did originally-so I’ve tried copy and pasting in both plain text and my code editor) on my PC and report back. I’m wondering if the type is getting mixed up in the cutting and pasting, depending on what editor I’m using vs. what the original code was written in. Oh the little details!
Keep me updated if anyone figures it out or has any other suggestions. Thanks!
PS. I’m also going to mess around with the modes and try ‘t’ vs. ‘b’ etc. as apposed to ‘rb’. Somebody let me know if I’m way off in left field on this one, please!
To be honest I never tested this in a Mac. File permissions could be different. I never tested this on a Windows server. Only on Linux.
I’ll need to have a look at this code since it appears to be causing people issues sometime in the near future. Maybe I can come with another solution.
Hi Cristian, I’ve added the child theme, and the header image, however now the title shows up in the left under the menu. How can I hide it ?
(if I dont use a title than it doesnt show up but there will be no title in the window browser)
You might have to edit your css file to move the title around.
Hi!
Can you provide a link to your site?
4 Trackbacks
[...] Add a Header Image to Thematic the Easy Way [...]
[...] Add a header image to Thematic – the easy way (tags: wordpress tutorial) [...]
[...] zupass kam, es um einen anpassbaren Kopf (neudeutsch: custom header) ergänzt, zu dem ich mich hier habe inspirieren [...]
[...] Add a Header Image to Thematic the Easy Way [...]