Export list of pretty permalinks and post title

后端 未结 3 646
庸人自扰
庸人自扰 2020-12-05 01:31

Looking for a way to export a list of pretty permalinks in WordPress with the corresponding post title. Looking for the actual permalink structure defined not the shortlink

3条回答
  •  广开言路
    2020-12-05 01:51

    answered this one on EE this morning :) http://wp.daveheavyindustries.com/2011/02/08/wordpress-permalink-via-sql/

    this query should do it for you

    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
      JOIN wp_options wpo
        ON wpo.option_name = 'permalink_structure'
       AND wpo.blog_id = 0
      JOIN wp_options wpo_su
        ON wpo_su.option_name = 'siteurl'
       AND wpo_su.blog_id = wpo.blog_id
     WHERE wpp.post_type = 'post'
       AND wpp.post_status = 'publish'
     ORDER BY wpp.post_date DESC 
    

提交回复
热议问题