This tutorial provides 2 ways to display different background images on different pages and posts of your site.
When you add an image using the Custom Background featured under your Appearance menu, it displays the image site wide.
If you want to display a different background image on one or more pages like your landing page, home page or front page, you need to follow 2 steps.
- Firstly, you’ll need to remove the custom background image from the specific page you want to replace with a different image.
- Secondly, you’ll need to add your image using CSS or another method. I’ll show you how to add the image using CSS.
1. Remove Custom Background Image From Specific Page
Here’s the PHP code you can use as is or in a custom function with conditional tag to remove the image.
2. Add Different Background Image Using CSS
And here’s the CSS code which pulls your new image from your child themes images folder if it matches the same file name, extension and path.
background-position: center center;
Clearly, you may like to change the values for some or all of the background properties in the CSS to suit your own requirements.
|the position of the background images
|the size of the background images
|how to repeat the background images
|the positioning area of the background images
|the painting area of the background images
|either the image is fixed or scrolls with the page
|the background color to be used
|the background images to be used
This post was written based on this question from Ted.
I’m using the Appearance > Background feature to upload a background image to be used throughout the site, but I’d like a different bg image for the home page.