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.com/jo, it still redirects me to the URL example.com/john-smith.

I've never seen this behaviour in WordPress before. Does anyone know what might be causing it?

  • 1
    Possibly: codex.wordpress.org/Function_Reference/… – jdm2112 Oct 11 '16 at 14:58
  • Have you tried saving / re-saving the permalinks preferences page so the redirects are re-generated? – tillinberlin Oct 11 '16 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.com/xxx... redirects to post for what xxx... is closest for. edit: If you had a page which url would be example.com/jo I don't think it would redirect you anywhere though... I don't see what's the problem here.. – jimihenrik Oct 11 '16 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 Oct 11 '16 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 Oct 11 '16 at 16:22

Add 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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