Reputation: 6205
I have tried to attach images to post by selecting it from the media and inserting it to the post. But when using the has_post_thumbnail() function, I am not getting the result as expected. Can anyone tell me how to attach a file to the post and get the source url of the attached file.
Upvotes: 0
Views: 332
Reputation: 3888
are you JUST using the has_post_thumbnail()
function?
has_post_thumbnail()
returns a boolean (True/False) value depending on whether or not there exists a thumbnail for said post. You want to add the function: the_post_thumbnail()
after that. Here is the code I use for post thumbnails:
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail(); // show the post's thumbnail
}
?>
Upvotes: 2