Issue
I want to display the featured image outside of the WP-loop. e. g. like a background image of the body that is different in every post. I looked for two hours on google, but could not find a single piece of code that gives me an idea. But I suppose it is not that much complicated.
Has anybody here an idea how the retrieve the URL of the featured image outside the loop?
thank"
Solution
Here's my preferred way:
<?php
$page = get_page_by_title('Title Here');
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' );
?>
<div class="background" style="background-image:url('<?php echo $image[0]; ?>');"/>
Answered By - androidoverlord
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.