Skip to content

Instantly share code, notes, and snippets.

View rohjay's full-sized avatar

Ryan Oeltjenbruns rohjay

View GitHub Profile
@rohjay
rohjay / wp-fix-search-typos.php
Created May 31, 2024 21:04
Example code that fixes common misspellings of words in seaches. Parameterize to taste 👍
<?php
add_action( 'pre_get_posts', function( $query ) {
if ( !$query->is_main_query() || !$query->is_search() ) {
return $query;
}
$common_misspellings = [
'lorem' => ['lorum', 'lorm', 'lormu', 'lormum', 'lormum'],
'ipsum' => ['ipusm', 'ipsums', 'ipsumz', 'ipsumz', 'ispum'],