• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Genesis 2.0 Custom Header Problem & Fix

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Genesis 2.0 Custom Header Problem & Fix

This topic is: not a support question

Tagged: Genesis 2.0 Header Issue

  • This topic has 5 replies, 5 voices, and was last updated 12 years, 7 months ago by IdleBuzz.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 14, 2013 at 3:07 pm #56405
    CyBorge
    Member

    I hope this helps some of you solve your Genesis 2.0 custom header issues. If you have a better solution please comment.

    My Issue:
    When I upgraded one of my sites to Genesis 2.0 - The custom header feature messed up the look of my header by creating an inline style using the !important
    Found here: /wp-content/themes/genesis/lib/structure AROUND LINE 783

    $output .= sprintf( '%s { background: url(%s) no-repeat !important; }', $header_selector, esc_url( $header_image ) );

    This line outputs the CSS bacground shortcut operator as an inline style with !important so it OVERRIDES your theme's CSS.

    NOTE - The background shortcut operator allows for background positioning - which this line doesn't define but, because it uses the !important and is an inline style it was OVERRIDING my existing CSS background-position declaration in my theme's style.css (with the defaults of left top) despite the fact that I used !important on the declaration:

    My CSS
    #header{
    background-position: center top !important;
    }

    My Solution - Added the code snippet below to my theme's functions.php so I could control the custom header's output and set the positioning I wanted:

    /*---------- MDB - CUSTOMIZE HEADER OUTPUT --------------- */
    remove_action( 'wp_head', 'genesis_custom_header_style' );

    add_action( 'wp_head', 'mh_custom_header_style' );

    function mh_custom_header_style() {

    //* Do nothing if custom header not supported
    if ( ! current_theme_supports( 'custom-header' ) )
    return;

    //* Do nothing if user specifies their own callback
    if ( get_theme_support( 'custom-header', 'wp-head-callback' ) )
    return;

    $output = '';

    $header_image = get_header_image();
    $text_color = get_header_textcolor();

    //* If no options set, don't waste the output. Do nothing.
    if ( empty( $header_image ) && ! display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) )
    return;

    $header_selector = get_theme_support( 'custom-header', 'header-selector' );
    $title_selector = genesis_html5() ? '.custom-header .site-title' : '.custom-header #title';
    $desc_selector = genesis_html5() ? '.custom-header .site-description' : '.custom-header #description';

    //* Header selector fallback
    if ( ! $header_selector )
    $header_selector = genesis_html5() ? '.custom-header .site-header' : '.custom-header #header';

    //* Header image CSS, if exists
    if ( $header_image )
    $output .= sprintf( '%s { background: url(%s) no-repeat center top !important; }', $header_selector, esc_url( $header_image ) );

    //* Header text color CSS, if showing text
    if ( display_header_text() && $text_color !== get_theme_support( 'custom-header', 'default-text-color' ) )
    $output .= sprintf( '%2$s a, %2$s a:hover, %3$s { color: #%1$s !important; }', esc_html( $text_color ), esc_html( $title_selector ), esc_html( $desc_selector ) );

    if ( $output )
    printf( '<style type="text/css">%s</style>' . "\n", $output );

    } /*------------ END HEADER FIX MDB ----------------------------------*/

    August 15, 2013 at 5:23 am #56508
    IdleBuzz
    Member

    Thanks for taking the time to post this CyBorge, but when I added your fix to my functions.php file, it locked me out of the site completely with a "server error", including blocking the main url to visitors.

    I have the same issue as you, my header is thrown to the left of the window now and Genesis 2.0 is ignoring my css styling to have it as follows:

    #header {
    background-size: contain !important;
    }

    #header {
    background-position: center !important;
    }

    Does anyone else have a potential solution? Or is there some way I can alter what you have provided CyBorge?

    Thanks!

    August 17, 2013 at 5:17 am #57023
    mcgratk
    Member

    Yes, thank you CyBorge. I'm having the same issue. Any advice is greatly appreciated!

    August 19, 2013 at 2:45 am #57274
    Robin
    Participant

    After changing my CSS and functions.php to HTML 5, mine did the same thing. my header was all the way to the left and the menu nav bar was pulled up.

    I cleared my cache and it was fine. Hope this will work for you as well.

    Robin

    August 19, 2013 at 9:39 pm #57484
    wendycholbi
    Member

    I think the problems that IdleBuzz and mcgratk are having may be caused by pasting in code that has curly quotes.

    I created a gist of CyBorge's code, with the curly quotes replaced with straight quotes, here:

    https://gist.github.com/wendycholbi/6276778

    ...and a separate one for anyone using the Prose theme (because the Custom Functions field in Prose was modifying the output and printing a single character at the top of the site) here:

    https://gist.github.com/wendycholbi/6276816

    I can verify that my Prose variation is working (my example site, using this function, is http://style3.sitesetupkit.com/ ), and CyBorge's code worked for me too, once I fixed the curly/straight issue.


    I love WordPress, Genesis, and the Prose child theme (my complete guide to using Prose is here: SiteSetupKit.com). Say hi on Twitter: @wendycholbi

    August 22, 2013 at 9:27 am #58212
    IdleBuzz
    Member

    Thanks wendycholbi! I appreciate the help 🙂 Now, do you have a suggestion for the mis-aligning of the menu now as well? Mine has zoomed all the way to the left of the page, instead of staying within the theme content parameters...

    I was sorely disappointed to see the latest genesis update not include anything for either of these issues, that are clearly affecting quite a few users...

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble