Skip to content

Instantly share code, notes, and snippets.

@justinribeiro
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinribeiro/9262457 to your computer and use it in GitHub Desktop.
Save justinribeiro/9262457 to your computer and use it in GitHub Desktop.
Get a list of permalinks from Wordpress 3.8 via MySQL
SELECT
wpp.post_title,
wpp.guid,
wpp.post_date,
CONCAT(wpo_su.option_value, 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
INNER JOIN wp_options wpo
ON wpo.option_name = 'permalink_structure'
INNER JOIN wp_options wpo_su
ON wpo_su.option_name = 'siteurl'
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