Get featured image via post ID
-
Is there a quick short amount of code to display a specific post’s featured image using its id?
Or grab that posts featured image, extract the image’s url and then input it into a img tag?
For the life of me I can’t get anything to work. I do have thumbnails enabled in my functions by the way.
something like:
<?php $post = get_post(10); $thumbnail = $post->get_the_post_thumbnail(); ?> <div id="image1"><?php echo $thumbnail; ?></div>or
<?php $post_id = 10; $thumb = get_the_post_thumbnail($post_id); echo '<div id="image1">'.$thumb.'</div>'; ?>Something along those lines. I did come across wp_get_attachment_url but I’m not sure how to implement it in my case.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Get featured image via post ID’ is closed to new replies.