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 Answer
1

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

Leave a Reply

Your email address will not be published. Required fields are marked *