Hi there – I’m trying to engineer random backgrounds in grid cells, but I’m getting tripped up by a very basic thing. I’ve added this code to my Pro child functions.php, but it’s not showing up in the head content as expected, so my php call later on is doing nothing:
/* random images */
add_action( ‘wp_head’, ‘designbg’ );
function designbg(){
$bg = array(’/wp-content/uploads/2020/06/farm.poster.plain_.jpg’, ‘/wp-content/uploads/2020/05/maglayout.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
};
Doesn’t make a difference if the add_action is before or after the function.
This is at http://beta.cheshiredave.com.
What am I doing wrong?
Thanks,
Cheshire