Skip to content

Instantly share code, notes, and snippets.

@allyburns
Created June 14, 2023 15:01
Show Gist options
  • Save allyburns/937b36412c6f100522526cfb797c37dd to your computer and use it in GitHub Desktop.
Save allyburns/937b36412c6f100522526cfb797c37dd to your computer and use it in GitHub Desktop.
SELECT
p.ID AS post_id,
p.post_type,
p.post_name AS slug,
p.post_status,
p.post_title,
p.post_date,
u.display_name AS author,
p.post_modified,
pm.meta_value AS whereverly_id,
CONCAT(
'https://example.com/',
file_meta.path
) AS image_url
FROM
wp_posts p
LEFT JOIN wp_users u ON
p.post_author = u.ID
LEFT JOIN wp_postmeta pm ON
pm.post_id = p.ID AND pm.meta_key = 'whereverly_id'
LEFT JOIN wp_postmeta thumbnail_meta ON
thumbnail_meta.post_id = p.ID AND thumbnail_meta.meta_key = '_thumbnail_id'
LEFT JOIN wp_posts im ON
thumbnail_meta.meta_value = im.ID
LEFT JOIN wp_as3cf_items file_meta ON
file_meta.source_id = im.id AND source_type = "media-library"
WHERE
p.post_status = 'publish' AND p.post_type IN('point_of_interest', 'post', 'event');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment