Last active
August 29, 2019 16:26
-
-
Save MarcJandt/300e491cc678a544c3ee740b4d7122fb to your computer and use it in GitHub Desktop.
SQL query to list all post's permalinks in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 AS wpp | |
JOIN wp_options AS wpo | |
ON wpo.option_name = 'permalink_structure' | |
JOIN wp_options AS 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