Skip to content

Instantly share code, notes, and snippets.

@TreyOverton
Created July 11, 2017 21:57
Show Gist options
  • Save TreyOverton/0311d7925654f19f6664b27f9891af0e to your computer and use it in GitHub Desktop.
Save TreyOverton/0311d7925654f19f6664b27f9891af0e to your computer and use it in GitHub Desktop.
A query to get the most recent post IDs from WordPress, one most recent from two different post types
(select ID, max(post_date) as max_post_date, post_type from wp_posts where post_type = 'post' and post_status='publish' group by id order by max_post_date desc limit 1)
union
(select ID, max(post_date) as max_post_date, post_type from wp_posts where post_type = 'event' and post_status='publish' group by id order by max_post_date desc limit 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment