Reputation: 13
How to include image path to background-image in Wordpress correctly? Cause this isn't working for me
<div class="slide" style="background-image: url("<php bloginfo('template_url'); ?> /assets/img/slide1.jpg");">
Upvotes: 1
Views: 384
Reputation: 1957
You are trying it in a wrong way. Reference : Check Here
Replace your code with:
<div class="slide" style="background-image: url('<?php echo get_template_directory_uri(); ?>/assets/img/slide1.jpg');">
Upvotes: 3
Reputation: 1716
Are you sure u didn't mess with your theme options? because that thing should just work. Check the documentation: https://developer.wordpress.org/reference/functions/bloginfo/
It is noted to use get_template_directory_uri()
instead for the parent template directory or get_stylesheet_directory_uri()
for the child template directory
Upvotes: 0