Skip to content

Instantly share code, notes, and snippets.

@alanzhaonys
Last active November 1, 2018 14:10
Show Gist options
  • Save alanzhaonys/9d805ef526e66b298cb9b6dda75150e6 to your computer and use it in GitHub Desktop.
Save alanzhaonys/9d805ef526e66b298cb9b6dda75150e6 to your computer and use it in GitHub Desktop.
SELECT wpp.post_title, wpp.guid, wpp.post_date,
concat('https://www.mydomain.com', REPLACE( REPLACE( REPLACE( REPLACE( wpo.option_value, '%year%', DATE_FORMAT(wpp.post_date,'%Y') ), '%monthnum%', DATE_FORMAT(wpp.post_date, '%m') ), '%day%', DATE_FORMAT(wpp.post_date, '%d') ), '%postname%', wpp.post_name )) AS permalink
FROM wp_posts wpp
JOIN wp_options wpo
ON wpo.option_name = 'permalink_structure'
WHERE wpp.post_type = 'post'
AND wpp.post_status = 'publish'
ORDER BY wpp.post_date DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment