admin管理员组

文章数量:1402788

On one of my pages I changed the slug to form a different URL. E.g.

Old:

New:

WordPress has done it's thing of redirecting to .

I'd like to remove this behaviour as a plugin I am using makes use of the slug in question and the redirect overrides its behaviour.

I checked this question, and checked my wp_postmeta table for instances of _wp_old_slug but nothing is returned. My server is Nginx so shouldn't be affected by .htaccess files.

Is there anything else I can do to remove this redirect?

On one of my pages I changed the slug to form a different URL. E.g.

Old: http://example/old-slug

New: http://example/new-slug

WordPress has done it's thing of redirecting http://example/old-slug to http://example/new-slug.

I'd like to remove this behaviour as a plugin I am using makes use of the slug in question and the redirect overrides its behaviour.

I checked this question, and checked my wp_postmeta table for instances of _wp_old_slug but nothing is returned. My server is Nginx so shouldn't be affected by .htaccess files.

Is there anything else I can do to remove this redirect?

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Apr 8, 2015 at 13:36 harrygharryg 7635 gold badges11 silver badges23 bronze badges 1
  • 2 It seems odd that your wp_postmeta table wouldn't have any _wp_old_slug keys - the bit of code that does that is in wp-includes/query.php (wp_old_slug_redirect()) - you could add an exit or debug statement there to check if it's being called. Also, remember that if WordPress can't find a permalink, it looks posts which match the start, e.g. if you had a post called /foobar, then /foo will redirect to it. – William Turrell Commented Apr 8, 2015 at 14:11
Add a comment  | 

5 Answers 5

Reset to default 7

This (in your functions.php) will turn it off (but see also the comment I've left):

remove_action('template_redirect', 'wp_old_slug_redirect');

It seems odd that your wp_postmeta table wouldn't have any _wp_old_slug keys - the bit of code that does that is in wp-includes/query.php (wp_old_slug_redirect()) - you could add an exit or debug statement there to check if it's being called.

Also, remember that if WordPress can't find a permalink, it looks for posts with a matching beginning, e.g. if you had a post with permalink /foobar, then /foo will redirect to it.

this worked for me:

   remove_filter('template_redirect', 'redirect_canonical');  

source: http://biostall/prevent-wordpress-redirecting-to-nearest-matching-url/

Every WordPress post has its own slug, which is automatically generated by your post’s title. If you decide to change the post slug later, WordPress will remember the old one and redirect it to the new one. It’s possible to prevent old post slug redirection in WordPress by adding removing a couple of actions from your WordPress core with a small snippet.

Just add following code to your current theme’s functions.php file to prevent WordPress from redirecting old post slugs to new ones:

remove_action( 'template_redirect', 'wp_old_slug_redirect'); 
remove_action( 'post_updated',      'wp_check_for_changed_slugs', 12, 3 );

To manually remove automatic redirects after slug change, just delete the corresponding rows from the "wp-redirection-items" from the database using phpMyAdmin.

This is the best and simplest way which allows you to remove redirects for specific posts.

What helped for was permalinks reset. just go to Settings -> Permalinks, pick default, hit Save Changes. Then pick your structure and hit Save Changes again.

本文标签: permalinksRemoving the redirect after changing a page39s slug