Last active
January 5, 2021 09:56
-
-
Save jchristopher/be9518446b5a76fe429c3f00e0eec0d0 to your computer and use it in GitHub Desktop.
Add custom regular expression pattern to SearchWP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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