Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //in the functions.php
- add_action('parse_request','oldsite_redirect',0); // 0=before (most) 'parse_request' calls
- function oldsite_redirect() {
- if (isset($_GET['lid'])) {
- global $wpdb;
- $sql = "SELECT post_id FROM {$wpdb->postmeta} " .
- "WHERE meta_key='lid' AND meta_value='%s'";
- $sql = $wpdb->prepare($sql,$_GET['lid']);
- $post_id = $wpdb->get_var($sql);
- if ($post_id) {
- $permalink = get_permalink($post_id);
- if ($permalink) {
- wp_safe_redirect($permalink,301);
- exit;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement