WordPress.org

Ready to get started?Download WordPress

Forums

Header Automatic Change (7 posts)

  1. MetalTiger
    Member
    Posted 9 years ago #

    I would like to be able to rotate the kubrickheader from a bank of photographs with each refresh. This is outside the relm of WordPress program, it would have to be an add on or plug-in. Any ideas on how to go about this?

    Sounds like a neat idea for http://metaltiger.org

    Thanks for the suggestions.

  2. kjarrett
    Member
    Posted 9 years ago #

  3. ceo
    Member
    Posted 9 years ago #

    Uhh, I think Matt's Random Image Script is more what MetalTiger had in mind.

  4. mike3k
    Member
    Posted 9 years ago #

    I just did it. See it at http://www.mcdevzone.com/

    I have a series of images kubrickheader0.jpg - kubrickheader7.jpg in my images directory and I added the following script to header.php:

    <?php
    function header_graphic() {
    echo "/images/";
    $num=rand(0,7);
    echo "kubrickheader".$num.".jpg";
    };
    ?>

    Finally, I changed the stylesheet header element as follows:

    #header { background: url("<?php bloginfo('stylesheet_directory'); header_graphic(); ?>") no-repeat bottom center; }

  5. bl
    Member
    Posted 9 years ago #

    Mike, your solution looks easy. Famous last words... :-)

    Clearly, I'm doing something wrong. I cut and past the php function and put it at the very top of my header.php file (the one in the themes/default directory).

    I then replaced the uncommented line that starts with #header in the same header.php file with the header element shown.

    I placed 9 images named kubrickheader0.jpg through kubrickheader9.jpg in the themes/default/images directory.

    Now, my header is just a blue box and the footer is a gray box. I didn't think I did anything to the footer.

    What did I do wrong?

    http://blogan.net

  6. MetalTiger
    Member
    Posted 9 years ago #

    Thank you all so much. This gives me something to work on. Thank you again.

  7. bl
    Member
    Posted 9 years ago #

    Thank you, Mike! With your help, I was able to get it working. Turns out, I was putting the php function at the very top of the header.php file, when it should go after the DOCTYPE and html lines and before the head line.

    I documented it in more detail in this article.

Topic Closed

This topic has been closed to new replies.

About this Topic