0

Wordpress post favorite image not showing on wp-admin and on page although it is set on DB. I have inserted posts with unnecessary data and post meta in DB from other db, all is ok. When I call thumbnail url like this , it is working

$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
echo $url;

But when I run it like this, not working, also not showing the image on post edit page on wp-admin.

echo get_the_post_thumbnail();

What I have missed?

Images urls are from the same server, but from different domains. website I am working in is website.tv/sub (another WP project), but the images urls are come from website.tv(the main WP project).

  • When you say image URLs from the same server but different domains, what do you mean? Featured images are just attachment IDs, they aren't URLs ( if you've stored a URL rather than an ID then that's not how it's supposed to work ). Also to be specific, you're getting output, but it's the wrong URL? Or you're getting no output? Or it's garbled output? Or an error object? A fatal error? Please be specific and precise in your wording so we don't misunderstand – Tom J Nowell Aug 4 '17 at 18:54
1

You have to echo it out:

echo get_the_post_thumbnail();

Perhaps you meant to use the_post_thumbnail();

https://developer.wordpress.org/reference/functions/the_post_thumbnail/

  • I do echo, I have also tried the the_post_thumbnail(), but nothing works. just missed it in question. – Anna Gabrielyan Aug 3 '17 at 23:43
0

As you said the images are from another domain, it won't load. Check the database for 'siteurl' and 'home' columns in YOUR_TABLE_PREFIX_options table have the correct url that you're working on.

Probably this may be the problem

website.tv/sub and website.tv(the main WP project).

Your main WP project is overriding the urls of your sub project. Try to move your sub project to a sub domain (sub.website.tv)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.