Need help adding code for Custom Headers in Wordpress 3.0

Discussion in 'WordPress' started by Alanaj, Jul 5, 2010.

  1. #1
    Hi All,

    I want to enable the "Header" feature under "Appearance" in the WP control panel that will allow me to upload headers from my computer. I have the following code, but I don't know where exactly to add it or the path. I'm new to WP so I don't want to screw anything up in my Hostgator Account/folders/files. Any help, step by step tutorial, video or images will be GREATLY appreciated.

    Thanks so much!

    http://millionclues.com/problogging/wordpress-tips/make-your-theme-wordpress-3-0-compatible/

    Custom Headers in WordPress 3.0 - Add this to your functions.php:

    define( 'HEADER_IMAGE', '%s/images/logo.png' ); // The default logo located in themes folder
    define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 770 ) ); // Width of Logo
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 153 ) ); // Height of Logo
    define( 'NO_HEADER_TEXT', true );
    add_custom_image_header( '', 'admin_header_style' ); // This Enables the Appearance > Header
    // Following Code is for Styling the Admin Side
    if ( ! function_exists( 'admin_header_style' ) ) :
    function admin_header_style() {
    ?>
    <style type="text/css">
    #headimg {
    height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
    width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
    }
    #headimg h1, #headimg #desc {
    display: none;
    }
    </style>
    <?php
    }
    endif;

    Use the Following hook in header.php to link to the header image:

    <?php header_image(); ?>

    Example -

    <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="Header Image" />
     
    Alanaj, Jul 5, 2010 IP
  2. bhuthecoder

    bhuthecoder Member

    Messages:
    245
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    43
    #2
    first take backup


    open the function.php file located in your theme directory

    and add the following code
    
    
    define( 'HEADER_IMAGE', '%s/images/logo.png' ); // The default logo located in themes folder
    define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 770 ) ); // Width of Logo
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 153 ) ); // Height of Logo
    define( 'NO_HEADER_TEXT', true );
    add_custom_image_header( '', 'admin_header_style' ); // This Enables the Appearance > Header
    // Following Code is for Styling the Admin Side
    if ( ! function_exists( 'admin_header_style' ) ) :
    function admin_header_style() {
    ?>
    <style type="text/css">
    #headimg {
    height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
    width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
    }
    #headimg h1, #headimg #desc {
    display: none;
    }
    </style>
    <?php
    }
    endif;
    
    Code (markup):

    open header.php located in your theme directory and add following code
    
    <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="Header Image" /> 
    
    Code (markup):
     
    bhuthecoder, Jul 5, 2010 IP
  3. Alanaj

    Alanaj Active Member

    Messages:
    108
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Thanks so much Bhuthecoder.
     
    Alanaj, Jul 6, 2010 IP