Ever want to have a random style applied on every page load? It could be a random color scheme, a background image, or anything else you can imagine.
If we tried to add a random body class with PHP (a server-side language) on a cached page, the applied styles would persist until the page cache was cleared, defeating the purpose of this technique.
And because we’re using a body class, we have flexibility to style whatever we want on the page, because we’re cascading as high as possible.
The use case we’ll cover in this tutorial will illustrate how to have a different header background image display on each page load. Specifically, we’ll be extending our page-specific header image tutorial to use random header images instead.
Let’s dig in!