Giving your users changeable or custom headers in themes

Built in to WordPress, and also available for WordPress MU, is the Custom header API. This service allows you to quickly add some code to a theme’s fuinctions.php file to make the header area completely customizable. User will be able to upload a header image of their choice on their chosen theme, without affecting other blogs using the same theme.

You may want to try this first on a test site of WPMU.

First, check and see if your theme has a functions.php file included. If it doesn’t, make a blank file called functions.php. If it already has code in it, which it will if the theme is widget enabled, then you can paste this code in right before the last ?> tag.

//make changeable header

define('HEADER_TEXTCOLOR', '');
define('HEADER_IMAGE', 'setta.jpg'); // %s is theme dir uri and image filename
define('HEADER_IMAGE_WIDTH', 985);  // make sure these values match the theme header
define('HEADER_IMAGE_HEIGHT', 200);
define( 'NO_HEADER_TEXT', true );

function atypxmas_admin_header_style() {   // change atypxmas to your theme name
?>

// this part adds the header in the admin area
#headimg {
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
}

#headimg h1, #headimg #desc {
display: none;}
}

function header_style() {
?>

#header{
background: url(<?php header_image() ?>) no-repeat;}
}

add_custom_image_header(’header_style’, ‘atypxmas_admin_header_style’);  // change atypxmas to your theme name you used above.

And that’s it! Everything else is handled internally by WordPress. To make things even easier, here’s a copy of a sample functions.php file. Please read the code and change the values accordingly for your specific theme, including the filename.

10,803 thoughts on “Giving your users changeable or custom headers in themes

  1. porn

    Just desire to say your article is as astonishing. The clarity to your post is just nice and that i can assume you’re an expert on this subject. Well with your permission let me to grab your RSS feed to stay up to date with impending post. Thank you one million and please keep up the enjoyable work.|

  2. porn

    I’m not sure exactly why but this website is loading incredibly slow for me. Is anyone else having this issue or is it a problem on my end? I’ll check back later and see if the problem still exists.|

  3. porn

    Having read this I believed it was really informative. I appreciate you taking the time and effort to put this content together. I once again find myself spending a significant amount of time both reading and leaving comments. But so what, it was still worth it!|

  4. porn

    I do believe all of the ideas you’ve presented on your post. They are really convincing and will certainly work. Nonetheless, the posts are very brief for starters. Could you please lengthen them a bit from subsequent time? Thanks for the post.|

  5. viagra

    I always used to read post in news papers but now as I am a user of web therefore from now I am using net for content, thanks to web.|

  6. porn

    I am really inspired together with your writing talents as neatly as with the layout to your weblog. Is that this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it is uncommon to look a great weblog like this one today..|

  7. porn

    My brother recommended I might like this website. He was totally right. This post truly made my day. You can not imagine just how much time I had spent for this info! Thanks!|

  8. sex

    You really make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand. It seems too complex and extremely broad for me. I am looking forward for your next post, I’ll try to get the hang of it!|

  9. porn

    Heya i am for the primary time here. I came across this board and I in finding It really helpful & it helped me out a lot. I’m hoping to present one thing again and help others such as you helped me.|

  10. porn

    Does your website have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it expand over time.|

  11. porn

    Thanks for a marvelous posting! I seriously enjoyed reading it, you happen to be a great author.I will remember to bookmark your blog and definitely will come back in the foreseeable future. I want to encourage you to continue your great posts, have a nice afternoon!|

  12. porn

    This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your excellent post. Also, I have shared your website in my social networks!|

  13. sex

    With havin so much written content do you ever run into any issues of plagorism or copyright infringement? My site has a lot of completely unique content I’ve either created myself or outsourced but it appears a lot of it is popping it up all over the web without my authorization. Do you know any ways to help protect against content from being stolen? I’d really appreciate it.|

  14. porn

    Wonderful blog you have here but I was wondering if you knew of any discussion boards that cover the same topics discussed in this article? I’d really love to be a part of community where I can get feedback from other knowledgeable people that share the same interest. If you have any recommendations, please let me know. Thanks a lot!|

  15. porn

    Hello to every one, the contents present at this site are genuinely amazing for people experience, well, keep up the nice work fellows.|

  16. 91 Club

    I love what you guys are up too. This type of clever work and reporting! Keep up the wonderful works guys I’ve incorporated you guys to my personal blogroll.|

  17. 91 Club

    When some one searches for his necessary thing, so he/she needs to be available that in detail, so that thing is maintained over here.|

Leave a Reply

Your email address will not be published. Required fields are marked *