Make WordPress Core

Opened 8 years ago

Last modified 7 years ago

#36420 new enhancement

A more forgiving redirect guesser

Reported by: gorillum's profile gorillum Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Canonical Keywords: dev-feedback 2nd-opinion
Focuses: Cc:


I would like the redirect guesser to be more forgiving using SOUNDS LIKE . Here's a small suggestion:

function redirect_guess_404_permalink() {
        global $wpdb;

        if ( get_query_var('name') ) {
                $where = $wpdb->prepare("(post_name SOUNDS LIKE %s", $wpdb->esc_like( get_query_var('name') ) );
                $where .= $wpdb->prepare(" OR post_name LIKE %s)", $wpdb->esc_like( get_query_var('name') ) . '%');


It would be even better if it could be implemented using levenstein distance if that is not too heavy on resources.

Change History (3)

#1 @Presskopp
8 years ago

While this sounds like a good idea, I have some notes:

MySQL SOUNDS LIKE is used as SOUNDEX(expr) = SOUNDEX(expr) to retrieve strings sounds similar.
Soundex is a phonetic algorithm for indexing names after English pronunciation of sound.

Not everyone uses an english environment, so this would be exclusive for the english..

The LIKE operator is commonly used to select data based on patterns. Using the LIKE operator in the right way is essential to increase the query performance.

Hmm. Do we want to be performant here?

And if i understand it right, the Damerau–Levenshtein distance would fit even better?

That's all I can say, please tell me if I'm wrong somewhere

Last edited 8 years ago by Presskopp (previous) (diff)

#2 @Presskopp
8 years ago

  • Keywords dev-feedback 2nd-opinion added

This ticket was mentioned in Slack in #core by presskopp. View the logs.

7 years ago

Note: See TracTickets for help on using tickets.