Sql query: how to grab the "file url" of each recognized image in wordpress?
What is the sql query to grab the "file url" of each recognized image (original image / example: http://www.mysite.com.com/wp-content/uploads/2012/photo.jpg ) and add it to the beginning relevant post like this example: [wide] http://www.mysite.com.com/wp-content/uploads/2012/photo.jpg [/ wide]
+3
source to share
2 answers
depending on what you want to do, the best option would be the one suggested by @Sheikh, but if you want to do something different and need a sql query, this query will get all the urls to be displayed:
SELECT ( SELECT guid FROM wp_posts WHERE id = m.meta_value ) AS url
FROM wp_posts p, wp_postmeta m
WHERE p.post_type = 'post'
AND p.post_status = 'publish'
AND p.id = m.post_id
AND m.meta_key = '_thumbnail_id'
Remember, you can also use this filter:
add_filter('the_content', 'add_post_content');
+4
source to share