How can I get featured image url directly, so I can use it for background
Just following the below example which tell you how to get your featured image’s url
<?php if (has_post_thumbnail( 'single-post-thumbnail' )) : ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?> <div id="custom-bg" style="background-image: url('<?php echo $image; ?>')"> </div> <?php endif; ?>
<?php if (has_post_thumbnail( 'single-post-thumbnail' )) : ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?> <div id="custom-bg" style="background-image: url('<?php echo $image; ?>')"> </div> <?php endif; ?>