Miker
Miker

Reputation: 194

Wordpress featured image not working on homepage

I have tried and researched but can't find a solution to this. Basically I'm trying to display a particular post (post_id 1) on the homepage with its featured image.

The title and excerpt work fine, but the featured image does not.

<?php
$post_id = 1;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo "<h2>" . $title . "</h2>";
echo "<p>" . $queried_post->post_excerpt . "</p>";
the_post_thumbnail();
?>

Any suggestions would be helpful.

Upvotes: 0

Views: 488

Answers (1)

rdt.exe
rdt.exe

Reputation: 141

Try replacing:

the_post_thumbnail();

with:

echo get_the_post_thumbnail($post_id);

Upvotes: 1

Related Questions