• Resolved RossB

    (@rossb)


    I’m designing a website using a Twenty Twelve child theme. I have set the home page to Static and got it basically how I want it. However, I want some of the pages that are going to be menu items to have different backgrounds from the home page (and each other). I have not been able to figure out how to do this.

    I got as far as using Firebug to identify one of these menu item pages, then adding the following CSS to my style sheet:

    body.page-id-4 {
    background-color: #FF0000 !important;
    }

    It didn’t work. The page retains the same background as the Static home page. (Note: I actually want to use a different background image, not colour, but thought I’d try to get the colour to change first – seems simpler).

    There is a WP plugin that apparently assists in changing backgrounds on a per page/post basis, but I’d rather learn how to do it using CSS. I’m a beginner in this area, so am finding it daunting, but still want to persist until I get it right.

    If anyone is able to assist, would be most appreciative.

    Cheers
    Ross

Viewing 15 replies - 1 through 15 (of 18 total)
  • Site link for CSS issues is required.

    Thread Starter RossB

    (@rossb)

    Sorry, wasn’t aware of that. Link is here:

    https://ppredesign.perthpunk.com

    Cheers
    Ross

    Thread Starter RossB

    (@rossb)

    Not possible to have different backgrounds for different pages, folks? I’d have thought it would have been, but I can find absolutely NOTHING on this (that works) on the web, and from the absence of replies here, seems that’s just how it is.

    If anyone has any clue on this, would be most grateful for some pointers. It’s so easy to change backgrounds per page on web design software like clunky old FrontPage, I thought it would be relatively easy to do in WordPress…

    Cheers
    Ross

    Yep, it’s just a bit tricky because you have a custom background image set – which is loaded after the custom CSS – so try this:

    body.page-id-49 {
    background-color: #FF0000 !important;
    background-image: none !important;
    }

    Thread Starter RossB

    (@rossb)

    You did it! It works! Thank you thank you thank you, WPyogi!

    I had actually tried that line you added, but without the ‘!important’, which makes all the difference. Not only have you given me the solution I’ve been searching for high and low for days, but you have also explained why it works (custom background image being loaded after the custom CSS).

    Indebted.

    Cheers!
    Ross

    Thread Starter RossB

    (@rossb)

    Forgot to mark the thread resolved, which I’m now deliriously happy to do!

    LOL – yes, CSS can be annoyingly illusive sometimes! But that just makes the thrill of victory even sweeter?! ??

    Thread Starter RossB

    (@rossb)

    WPyogi, are you still there? I celebrated so joyously prematurely!

    I want to change the background IMAGE on a per page basis, not the colour. Now I’m stuck again, because whatever image I put in is overridden by the background image of the static home page.

    I know there must be some simple solution, but I can’t find it! If you could possibly pop back with another bit o sage advice, would be fabbo.

    Cheers
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Thread Starter RossB

    (@rossb)

    Thanks, Andrew, but as per my initial post I’m aware of that plugin. I’d rather learn how to do this using CSS, and am SOOO close. Once I’ve got the CSS right, I will know what to do from now on, and can do the same for all other pages without a plugin.

    Cheers
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Have you looked at using CSS background image?
    https://www.w3schools.com/cssref/pr_background-image.asp

    Remember, CSS is not WordPress-specific, there are plenty of useful resources like W3Schools that teach this.

    Thread Starter RossB

    (@rossb)

    I have now – thanks, Andrew.

    Whatever I try, the static home page image overrides the background image I try to put in for the new page. I can get a customised background colour to load when I revert to WPYogi’s CSS recommendation, but not a customised background image.

    It’s got me beat.

    Cheers
    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Instead of “background-image” try using “background”:

    body.page-id-49 {
     background: url("/wp-content/themes/yourTheme/path-to-image/image.png") !important;
    }

    Thread Starter RossB

    (@rossb)

    HA! That did it! Thanks so much, Andrew!

    Would you mind explaining briefly why that worked, and why you thought to change from background-image, pls?

    So relieved – was just about to quit for the day after hours wrangling with this. Very grateful to you.

    Ross

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Because your site wasn’t using the “background-image” property, it was using “background”.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Twenty Twelve: how to change background on a per/page basis’ is closed to new replies.