1

Would it be fairly simple to add different site header and menu styles and assign them to specific pages? I have very basic understanding of how CSS and php work and managed to customise the theme but this is way over my capabilities. Could someone tell what code to add where so I get header and main menu:

  1. on HOME - white site title, description and menu on black background,
  2. on other pages - black site title, description and menu on white background?
1

There are multiple ways to accomplish this. You could create a unique page template, enqueue a stylesheet just for the homepage, or use a unique class on the homepage.

This is probably the simplest.

If you inspect your homepage with the browser (press f12) and look at the body tag, you will notice WordPress is adding a .home class. You can use this to apply different styles that will only effect things on the homepage.

Here are a few examples based off what you were asking for.

.home .site-branding {
    background-color: #000;
}

.home .site-title a, 
.home .site-description {
    color: #fff;
}

I would recommend styling all the other pages how you want them and then using the .home class to change things on the homepage, like the above example. But you could do the opposite and target pages that do not have the .home class on the body.

For example...

body:not(.home) .site-branding {
    background-color: #fff;
} 

Note: Take a look a the body class on different pages, WP adds a unique class for pages, posts, templates, etc. to make things like this easy.

  • Thank you very much for taking time to look into my issue and for your advice! It obviously works ;) – el Huzar Dec 23 '18 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.