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.

8,610 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.|

Leave a Reply

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