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 |5 Answers
Reset to default 7This (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
版权声明:本文标题:permalinks - Removing the redirect after changing a page's slug 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744346422a2601787.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_postmeta
table wouldn't have any_wp_old_slug
keys - the bit of code that does that is inwp-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