Tagged: x
-
AuthorPosts
-
February 26, 2017 at 2:26 pm #1386398
bdestrempesParticipantHey guys,
I’m trying to set the featured image URL as the background image for the entry-featured div instead of calling it as an image within the div. Here is what I have so far:
<div class="entry-featured" <?php if (is_home()) echo 'style="background-image: url(' . the_post_thumbnail_url('thumbnail') . '"'; ?> >However, the end result is this:
<div class="entry-featured" http:="" localhost="" wp-content="" uploads="" 2017="" 02="" the-three-people-you-meet-on-earth-150x150.jpgstyle="background-image: url(">I know I’m probably missing something really simple but my PHP skills are quite lacking. Any help would be appreciated.
February 26, 2017 at 8:13 pm #1386683
LelyModeratorHi There,
No need to use the echo function because the the_post_thumbnail_url function returns the URL already. Please use something like this instead:
<?php if (is_home()){ ?> <div class="entry-featured" style="background-image: url(<?php the_post_thumbnail_url('thumbnail'); ?>"> <?php }else {?> <div class="entry-featured"> <?php }?>Hope this helps.
February 26, 2017 at 9:09 pm #1386738
bdestrempesParticipantThat did it, thanks a lot!
February 26, 2017 at 11:12 pm #1386843
LelyModeratorYou’re welcome!
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1386398 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
