So I have a feeling this is quite simple, but Im a bone head since I'm still learning PHP as I hack away at themes via my own child-theming...

In short, I've built a customizer section in my functions.php where I can add my own background image that I would then like to fetch in my search.php template and output as a inline background-image style. As far as I can tell, Im just not formatting my php correctly but I do seem to be effectively calling the url into the page when it loads, just nothing happens yet.

Maybe someone can enlighten me on where Im screwing this up hopefully.


<header class="page-header search-header" style="background-image: url('
            <?php if ( get_theme_mod( 'hbps_searchresults_bg_img' ) > 0 ) { 
                echo wp_get_attachment_image_url( get_theme_mod( 'hbps_searchresults_bg_img' ), 'full' ); } ?> ');">

Thank you for your time.

Best, Shaun

  • 2
    It could be as simple as a space character. At the end of your code try } ?>');"> (delete the space between closing of PHP and the single quote at the end of the URL). – WebElaine Jul 5 '18 at 19:25
  • Geez, I cant believe it was even simpler than I anticipated, lol. THANK YOU! – Mr.Brown Jul 5 '18 at 22:32

Your Answer

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

Browse other questions tagged or ask your own question.