• 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

How to grab custom header image URL

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 › Design Tips and Tricks › How to grab custom header image URL

This topic is: not resolved

Tagged: header image

  • This topic has 5 replies, 2 voices, and was last updated 6 years ago by Victor Font.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • February 23, 2017 at 11:42 pm #201869
    SRD
    Member

    A WP site using a Genesis child theme has a web page with a Genesis custom header image:

    http://imgur.com/1UQubwl

    How do I grab this header image URL in PHP?

    I tried adding the following to the <head>:

        <style>
    		.entry-header {
    			background: url('<?php echo( get_header_image() ); ?>') no-repeat center center fixed;
    			-webkit-background-size: cover;
    			-moz-background-size: cover;
    			-o-background-size: cover;
    			background-size: cover;
    		}
         </style>

    but the url has an empty string returned.

    Help appreciated.

    http://roofspan.madhatmedia.com.au/
    February 24, 2017 at 5:50 am #201877
    Victor Font
    Moderator

    You can't execute PHP inside of CSS. CSS is client side code, PHP is server side code. If you want to execute PHP as part of CSS, you have to execute the entire file on the server. Create the CSS file as style.php, write the code as PHP, then enqueue it as a PHP script.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    February 24, 2017 at 5:58 am #201878
    SRD
    Member

    The PHP code is inside a function called to be added into the <head> already.

    The PHP code executes but the URL is an empty string.

    Cheers.

    February 26, 2017 at 9:16 pm #202049
    SRD
    Member

    Hello?

    March 9, 2017 at 4:58 am #202742
    SRD
    Member

    Hello? Are you there?

    March 9, 2017 at 6:30 am #202745
    Victor Font
    Moderator

    You are making a couple of assumptions that may not be true. The WordPress get_header_image() functions requires the theme support for custom headers is activated and that the image is assigned through the WordPress customizer. Since you are using the Genesis Custom Headers plugin to create the header image, you are bypassing the WordPress methods that allow the function to work.

    The plugin is from a third party without any affiliation to Studio Press. So questions regarding how the image url can be retrieved should be directed to the plugin developer. https://wordpress.org/support/plugin/genesis-custom-headers


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Design Tips and Tricks’ 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

© 2023 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