Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active January 5, 2021 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/be9518446b5a76fe429c3f00e0eec0d0 to your computer and use it in GitHub Desktop.
Save jchristopher/be9518446b5a76fe429c3f00e0eec0d0 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