0

I am using the Associate Theme based on the Genesis framework and I'm trying to use a background image and background colour in the header. Genesis seems to dynamically generate the CSS for this and I get:

.custom-header #header {
    background: url(http://xxxxx.png) no-repeat !important;
}

What I need is to change this to:

.custom-header #header {
    background: white url(http://xxxxx.png) no-repeat !important;
}

I cannot find where to do this and un-hooking the genesis header and manually coding it in seems to defeat the object of using the framework.

Does anyone know how I can achieve this, please?

2
  • Hook onto the same action that the genesis header function does and spit out <style>body.custom-header #header { background-color: white !important; }</style> - that should be sufficient to override the background color. Commented Feb 24, 2016 at 14:26
  • That worked! I just added your code and put it in the Genesis Simple Hooks for the genesis_header Hook. You can go ahead and add that as an answer. Cheers
    – TomC
    Commented Feb 24, 2016 at 15:39

1 Answer 1

2

Hook onto the same action as the genesis header function and kick out your overriding CSS:

function wpse_218701_genesis_header() {
    ?>

<style>
    body.custom-header #header {
        background-color: white !important;
    }
</style>

<?php
}

add_action( 'genesis_header', 'wpse_218701_genesis_header' );
4
  • One line 2 of your answer is that a PHP closing tag? Not saying I know better, I don't, trying to understand why (to me) the tags look backwards compared to tutorials like tutorialspoint.com/php/php_functions.htm, thanks for any help
    – JimLohse
    Commented Jun 29, 2019 at 13:51
  • 1
    You're right, it's a closing tag. With PHP you can "hop" back in and out of the parser using closing/opening tags (pretty much) anywhere. The alternative would be to echo the style tag in a string/nowdoc instead. Commented Jun 29, 2019 at 16:25
  • Mind blown. Thanks.
    – JimLohse
    Commented Jun 29, 2019 at 16:30
  • I've just come across this issue again and found your answer to my question 3 years ago!
    – TomC
    Commented Nov 26, 2019 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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