Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created January 23, 2015 15:40
Show Gist options
  • Save jchristopher/3f3038420876c71b42d7 to your computer and use it in GitHub Desktop.
Save jchristopher/3f3038420876c71b42d7 to your computer and use it in GitHub Desktop.
Selectively omit post meta (Custom Fields) from being indexed by SearchWP
<?php
function my_searchwp_omit_meta_key( $omit, $meta_key, $the_post ) {
// don't index anything marked as private (starts with _)
if ( '_' == substr( $meta_key, 0, 1 ) ) {
$omit = true;
}
return $omit;
}
add_filter( 'searchwp_omit_meta_key', 'my_searchwp_omit_meta_key', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment