This topic has 1 reply, 2 voices, and was last updated 11 years by SQadmin.

  • Author
  • #2440
     aero77
    Participant

    Is there a way to show a random background picture each time ? How would I do this and which file should I edit etc ?

    #2474
     SQadmin
    Keymaster

    This is a sample on how you could achieve that. It has to be added in the footer.php

    COPY CODE
    
    
    <?php
      $bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // array of filenames
    
      $i = rand(0, count($bg)-1); // generate random number size of the array
      $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
    ?>
    
    <style type="text/css">
    <!--
    body{
    background: url('<?php get_stylesheet_directory_uri(); ?> /images/<?php echo $selectedBg; ?>') no-repeat;
    }
    -->
    </style>
    

    Images must be placed in sweetdate-child/images and defined in the $bg array

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Landing page – background picture’ is closed to new replies.

Log in with your credentials

Forgot your details?