• I need to customize TwentyTen theme by adding random images.
    In WP 2.X theme “falling_dreams” I used this function:

    <?php
    function header_graphic() {
    echo “/images/”;
    $num=rand(0,24);
    echo “dream”.$num.”.jpg”;
    };
    ?>

    Then in <head> section included:

    #header {
    background: url(“<?php bloginfo(‘stylesheet_directory’); header_graphic(); ?>”) no-repeat bottom center;
    }

    And in the <body> section this line:

    <div id=”wrapper”>
    <h1 id=”header” onclick=”location.href='<?php bloginfo(‘url’); ?>’;” style=”cursor: pointer;”>

    And I had 25 header images appearing at random order.
    I wish I could do the same in TwentyTen theme, but as soon as I add header_graphic() function, I get an error message that this function is already defined in wp-includes/theme.php
    Can anyone post here what exactly where I need to change to show random images in the header?

Viewing 1 replies (of 1 total)
  • As a rule I prefix my functions so they do not conflict with any WordPress or PHP standard code calls, use a three digit prefix for your function and call like gun_.

    example:
    ?php
    function gun_header_graphic() {
    echo “/images/”;
    $num=rand(0,24);
    echo “dream”.$num.”.jpg”;
    };
    ?>

    and

    #header {
    background: url(“<?php bloginfo(‘stylesheet_directory’); gun_header_graphic(); ?>”) no-repeat bottom center;
    }

    David

Viewing 1 replies (of 1 total)
  • The topic ‘TwentyTen: how to add random images?’ is closed to new replies.