I have got a wordpress instance and i want to set background image inline a html tag via php function.
The html is:
<div id="content" class="site-content" <?php echo get_background_for_single(get_the_ID(), is_single()); ?>>
The above html and php has the following output in browser:
<div id="content" class="site-content" style="background-image: url(" http:="" localhost="" wiese="" wp-content="" uploads="" 2019="" 06="" test.jpg");="">
In the functions.php i got:
function get_background_for_single($ID, $single) {
if ($single == 1) {
return 'style="background-image: url("' . get_the_post_thumbnail_url($ID) . '");';
}
}
If i controll the output in a paragraph as follows, it is displayed correct:
<p><?php echo get_background_for_single(get_the_ID(), is_single()); ?><p>
It returns in a p tag:
style="background-image: url("http://localhost/wiese/wp-content/uploads/2019/06/test.jpg");
Why does the function return " ="" " instead of " / "? Perhaps it is a dump mistake, but i cannot see my mistake.