Random site background image
-
Hi
How can I implement a more efficient random site/body background image?
Currently I use something like this in child
functions.php
:function my_body_classes( $classes ) { $fileIndex = rand(1, 3); $className = 'my-background-image-' . (string)$fileIndex; $classes[] = $className; return $classes; } add_filter( 'body_class', 'my_body_classes' );
With hard-coded css classes like this:
.my-background-image-1{ background-image: ...1; } .my-background-image-2{ background-image: ...2; } .my-background-image-3{ background-image: ...3; }
Is it possible to dynamically send/create css classes or styles inside function.php so I have to create only one css class?
Or generally how can I dynamically create a random site backgroud image? Probably with a custom header.php?
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Random site background image’ is closed to new replies.