Fetch customizer image and output as an inline css style background image

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.

Example:

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

Topic theme-customizer get-theme-mod custom-background images Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.