0

enter image description here

First, On a clean Wordpress installation using Local, I name the project "example" I install this Custom Post Type UI Plugin Then I Activate it.

Then I have create a post type, suppose i name it "example".

enter image description here

Then I proceed to add this new custom post type "example" with post name "test" enter image description here

I got this permalink, which works fine http://example.local/example/test/

enter image description here

However, When I use link

http://example.local/example/t

I expected it to return some kind of page not found, But it redirect to

http://example.local/example/test/

If i use link http://example.local/example/a However, It will correctly go to 404 page not found

enter image description here

I think I do lack some basic understanding. How can I config it so when custom post type does not use exact existing post name It will go to 404 page instead of go to nearest page.

3
  • 1
    this isn't specific to custom post types, it happens to all post types. Note that it should be redirecting to the canonical URL, so if you have SEO concerns then they are unfounded, Google should see that http://example.local/example/t has a canonical URL tag of http://example.local/example/test and that it 302 redirects, so there are no SEO penalties for duplicate content
    – Tom J Nowell
    Nov 10, 2022 at 14:45
  • 1
    Also questions about the custom post type UI plugin are offtopic here, 3rd party plugin/theme dev support questions are offtopic and not in this stacks scope. For help with the CPT UI plugin you should go to the CPT UI plugin forums or support
    – Tom J Nowell
    Nov 10, 2022 at 14:46
  • So there is nothing we can do about this right ? Nov 10, 2022 at 16:59

1 Answer 1

2

Out of the box, WordPress will try to be helpful and provide the next best post if it cannot find the one you specified - in your case example/t.

This feature can be deactivated, however:

function stop_404_guessing( $url ) {
    return ( is_404() ) ? false : $url;
}
add_filter( 'redirect_canonical', 'stop_404_guessing' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.