Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I posted earlier about changing my site's CSS based on user-choice from a drop-down and storing it in a cookie, which I think I have now resolved, and sort-of have working at the following address http://somethingoriginal.net. However I am trying to change the header image alongside the theme and it is proving much more difficult than I first thought. I basically want to do this in my header.php file:

if(day theme)
 use day css (DONE)
 setDayHeader()
if(night theme)
 use night css (DONE)
 setNightHeader()

I have tried calling this from in functions.php which unfortunately does nothing, I know it is being called as I have checked using echo statemnets:

    function setDayHeader(){
         //Set header to day header
         $args = array(
         'width'         => 1000,
         'height'        => 288,
         'default-image' => get_template_directory_uri() . '/images/headers/SomethingOriginalSun.png',
         );
        add_theme_support( 'custom-header', $args );    


}

function setNightHeader(){
         $args = array(
         'width'         => 1000,
         'height'        => 288,
         'default-image' => get_template_directory_uri() . '/images/headers/SomethingOriginalTheMoonAndStars.png',
         );
         add_theme_support( 'custom-header', $args );       
}

And tried changing it directly within the HTML of the header.php file, starting here:

<div id="page" class="hfeed">
    <header id="branding" role="banner">

by changing the following line:

    <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />

Either by replacing header_image() with a variable or replacing it with a URL directly, but this just seems to make my header image disappear completely. I thought it was best to make a separate post for this as it now addresses different functionality than setting my stylesheet.

Thanks.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I had to take information from both of your posts to be able to come with something.

Try replacing

<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />

width

<?php
if (!(isset($_POST["styles"]))) { //if post not set (first visit)
    if ($_COOKIE["chosenStyle"] == "night") { 
        echo '<img src="'.get_template_directory_uri() . '/images/headers/SomethingOriginalTheMoonAndStars.png" width="1000" height="288" alt="Night Header" />';
    } else {
        echo '<img src="'.get_template_directory_uri() . '/images/headers/SomethingOriginalSun.png" width="1000" height="288" alt="Day Header" />';
    }
} else { //if post is set 
    if ($_POST["styles"] == "day") { 
        echo '<img src="'.get_template_directory_uri() . '/images/headers/SomethingOriginalSun.png" width="1000" height="288" alt="Day Header" />';
    } else {
        echo '<img src="'.get_template_directory_uri() . '/images/headers/SomethingOriginalTheMoonAndStars.png" width="1000" height="288" alt="Night Header" />';
    }   
}
?>

just remove you setNightHeader() and setDayHeader() functions

share|improve this answer
    
Hi Kim, sorry for the late reply, I've had difficulties accessing StackExchange from home. I'll try this and let you know! –  Vixxd Mar 13 '13 at 15:09
    
Worked, thank you! –  Vixxd Mar 21 '13 at 1:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.