Created
August 1, 2013 12:51
-
-
Save remcotolsma/6131041 to your computer and use it in GitHub Desktop.
Insert WordPress redirection items for the Redirection plugin (http://wordpress.org/plugins/redirection/) from WordPress post meta imported URL.
This file contains 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
INSERT | |
INTO wp_redirection_items ( | |
url , | |
group_id , | |
action_type , | |
action_code , | |
action_data , | |
match_type | |
) | |
SELECT | |
REPLACE( REPLACE(meta.meta_value, 'http://www.example.com', ''), 'http://example.com', '') AS url , | |
3 AS group_id , | |
'url' AS action_type , | |
'301' AS action_code , | |
CONCAT( 'http://www.example.com/?p=', post.id ) AS action_data , | |
'url' AS match_type | |
FROM | |
wp_posts AS post | |
RIGHT JOIN | |
wp_postmeta AS meta | |
ON | |
post.ID = meta.post_id | |
AND | |
meta.meta_key = '_import_url' | |
WHERE | |
post.guid != ''; |
INSERT
INTO wp_redirection_items (
url ,
group_id ,
action_type ,
action_code ,
action_data ,
match_type
)
SELECT
REPLACE( REPLACE(meta.meta_value, 'http://www.metaalmagazine.nl', ''), 'http://metaalmagazine.nl', '') AS url ,
3 AS group_id ,
'url' AS action_type ,
'301' AS action_code ,
CONCAT( 'http://www.metaalmagazine.nl/?p=', CAST( post.id AS CHAR(20) ) ) AS action_data ,
'url' AS match_type
FROM
wp_posts AS post
RIGHT JOIN
wp_postmeta AS meta
ON
post.ID = meta.post_id
AND
meta.meta_key = '_import_url'
WHERE
post.guid != '';
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍