Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Last active January 4, 2023 14:33
Show Gist options
  • Save searchwpgists/c283bd34a067c59be88fa1d6493bfaed to your computer and use it in GitHub Desktop.
Save searchwpgists/c283bd34a067c59be88fa1d6493bfaed to your computer and use it in GitHub Desktop.
Add custom regular expression pattern to SearchWP
<?php
// Add custom regular expression pattern to SearchWP.
add_filter( 'searchwp\tokens\regex_patterns', function( $patterns ) {
$my_patterns = [
"/([0-9]{1,2}\\/[0-9]{1,2})/is", // Retain measurement details.
];
// We want our pattern to be considered top priority.
return array_merge( $my_patterns, $patterns );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment