admin管理员组文章数量:1434924
I'm having a really weird issue. For example, there is a custom post 'people'. The post title is the name of the person and pretty permalinks are enabled. Say we have a person custom post with the name of 'John Smith' with a slug of 'john-smith'. If I visit the URL example/jo
, it still redirects me to the URL example/john-smith
.
I've never seen this behaviour in WordPress before. Does anyone know what might be causing it?
I'm having a really weird issue. For example, there is a custom post 'people'. The post title is the name of the person and pretty permalinks are enabled. Say we have a person custom post with the name of 'John Smith' with a slug of 'john-smith'. If I visit the URL example/jo
, it still redirects me to the URL example/john-smith
.
I've never seen this behaviour in WordPress before. Does anyone know what might be causing it?
Share Improve this question edited Oct 11, 2016 at 15:13 Max Yudin 6,3882 gold badges26 silver badges36 bronze badges asked Oct 11, 2016 at 14:37 hootsmctoots84hootsmctoots84 2111 gold badge2 silver badges5 bronze badges 6- 1 Possibly: codex.wordpress/Function_Reference/… – jdm2112 Commented Oct 11, 2016 at 14:58
- Have you tried saving / re-saving the permalinks preferences page so the redirects are re-generated? – tillinberlin Commented Oct 11, 2016 at 15:10
- 1 For me WP has worked this way as long as I can remember (well, for real at least a year or two now). So domain/xxx... redirects to post for what xxx... is closest for. edit: If you had a page which url would be example/jo I don't think it would redirect you anywhere though... I don't see what's the problem here.. – jimihenrik Commented Oct 11, 2016 at 15:22
- @jimihenrik - I've got quite a few sites on WP and none of them ever seem to redirect based on a partial match of the slug (just tried it now). This is issue is happening on a site built by somebody else. – hootsmctoots84 Commented Oct 11, 2016 at 15:43
- @jimihenrik - Actually just noticed this happens on one of my sites, but only on a custom post. It doesn't happen on a different site, even if the URL is only off by one character. Very weird. – hootsmctoots84 Commented Oct 11, 2016 at 16:22
1 Answer
Reset to default 1Add this code in your active theme's functions.php file and it should stop Wordpress guessing the source of the incomplete slug:
function no_redirect_guess_404_permalink( $header ){
global $wp_query;
if( is_404() )
unset( $wp_query->query_vars['name'] );
return $header;
}
add_filter( 'status_header', 'no_redirect_guess_404_permalink' );
Original answer here
本文标签: permalinksWordPress Custom Post Type is Matching on Partial Slug
版权声明:本文标题:permalinks - WordPress Custom Post Type is Matching on Partial Slug 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745615960a2666403.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论