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.

9,959 thoughts on “Giving your users changeable or custom headers in themes

  1. situs bokep

    Hi! I could have sworn I’ve been to this website before but after browsing through some of the post I realized it’s new to me. Nonetheless, I’m definitely glad I found it and I’ll be book-marking and checking back frequently!

  2. porn

    I am truly delighted to glance at this website posts which contains lots of useful data, thanks for providing these kinds of information.|

  3. porn

    hello there and thank you for your info – I have certainly picked up anything new from right here. I did however expertise some technical points using this website, since I experienced to reload the site a lot of times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I’m complaining, but slow loading instances times will sometimes affect your placement in google and could damage your quality score if advertising and marketing with Adwords. Anyway I am adding this RSS to my email and could look out for a lot more of your respective interesting content. Ensure that you update this again very soon.|

  4. scam

    Thank you, I have just been looking for info approximately this subject for ages and yours is the greatest I have discovered so far. However, what concerning the bottom line? Are you positive about the source?|

  5. scam

    I get pleasure from, cause I found exactly what I used to be looking for. You’ve ended my 4 day lengthy hunt! God Bless you man. Have a nice day. Bye|

  6. 遊雅堂のおすすめスロットやライブカジノ10選!

    ポーカーの役について、強さや確率、役の一覧などの情報を提供するウェブサイトがあります。ポーカーのやり方やルール、大会情報なども掲載されています。東京や大阪などの都市でポーカーを楽しむこともできます。初心者向けの基礎知識や戦略、強いカードや組み合わせについての情報もあります。オンラインで無料の対戦も可能です。さらに、ポーカー関連のニュースやトピックも提供しています。 -> https://wptjapan.com/yuugado-slots/ <- 遊雅堂のおすすめスロットやライブカジノ10選!

  7. scam

    Today, I went to the beach with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!|

  8. tree preservation policy

    Hi, I do believe your site might be having web browser compatibility problems. Whenever I look at your web site in Safari, it looks fine however when opening in IE, it has some overlapping issues. I simply wanted to give you a quick heads up! Apart from that, excellent site!

  9. fortnite hacks

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

  10. porn

    I was suggested this website by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my problem. You’re incredible! Thanks!|

  11. fortnite hacks

    I?m impressed, I must say. Actually hardly ever do I encounter a weblog that?s both educative and entertaining, and let me tell you, you’ve gotten hit the nail on the head. Your idea is outstanding; the problem is something that not enough individuals are speaking intelligently about. I am very happy that I stumbled across this in my search for one thing referring to this.

  12. scam

    I have been browsing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the web will be a lot more useful than ever before.|

  13. sex

    I have been surfing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. Personally, if all webmasters and bloggers made good content as you did, the web will be much more useful than ever before.|

Leave a Reply

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