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?

  • 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. – TheDeadMedic Feb 24 '16 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 Feb 24 '16 at 15:39
1

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' );
  • 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 Jun 29 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. – TheDeadMedic Jun 29 at 16:25
  • Mind blown. Thanks. – JimLohse Jun 29 at 16:30

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.