Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_deep_detect_permalinks() {
- global $wp, $wp_query;
- // Works only if 404 error is set before when the WP query is parsed
- if(empty($wp_query->query['do_not_redirect']) && is_numeric($wp->request)) {
- $post_id = (int) $wp->request;
- // Redirect to new permalink
- if($post_id) {
- $correct_permalink = get_permalink($post_id);
- wp_safe_redirect($correct_permalink, 301);
- }
- }
- }
- add_filter('template_redirect', 'pm_deep_detect_permalinks', 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement