Where is the featured image link stored in the WordPress Database? I searched in the wp_postmeta
table but I cannot find out the exact post_id
and links
.
Is this correct? Could anyone please explain to me how it works?
Where is the featured image link stored in the WordPress Database? I searched in the wp_postmeta
table but I cannot find out the exact post_id
and links
.
Is this correct? Could anyone please explain to me how it works?
I was curious, so here goes...
wp_postmeta
table will hold an entry for the post withmeta_key
of_thumbnail_id
meta_value
is a childpost_id
for the featured imagepost_id
, you can obtain further information fromwp_posts
andwp_postmeta
To put it all together, here's how to get the child
wp_posts
row for the featured image of postXXX
...And here's the meta data for that same image
The metadata will include a
_wp_attached_file
relative path, and a_wp_attachment_metadata
containing some PHP serialized data.here my sql with full url image
the result will be like this
Even if rnevius answer seemed correct, the result returned some images with this kind of URL : http://www.example.com/?attachment_id=48 which was not working in my case.
Tested on Wordpress 4.9.3 :
Another solution is to use
_wp_attached_file
instead :wp_postmeta
Search for value
_thumbnail_id
inmeta_key
wp_postmeta
Again in
wp_postmeta
, search for value_wp_attached_file
inmeta_key
wherepost_id
is matching themeta_value
find in previous queryQuery :
The featured image ID is stored in
wp_postmeta
with ameta_key
called_thumbnail_id
. Example:The actual thumbnail link is then contained in
wp_posts
with apost_type
ofattachment
. Example: