Site logo

Archived topic

How to set same background image on multiple (but not all) pages with one code

3 replies · Started by Roslyn on June 30, 2019

Viewing posts 1–4 of 4

Can I use one piece of code to set the same background image on multiple pages, rather than plugging each one in separately?

Here's the code I've been using, but now I'd like to use the same image for background on quite a few more pages:

body.page-id-xx {
background-image: url(http://IMAGE-URL-HERE);
}

Thank you for your assistance!

Hi there,

This is a tough one..

You could add a custom field to each page, and then add a body class to those pages if they have a custom field. I'm not sure it's worth the time to add the custom field, though?

It may be easier to just do this:

body.page-id-xx,
body.page-id-123,
body.page-id-456 {
    background-image: url(http://IMAGE-URL-HERE);
}

Yahoo!! That works great! (Oh, what a comma will do!)

Thanks very much!

You're welcome :)

This archived topic is closed to new replies.