Available since: 2.0
searchwp_omit_meta_key
View Parameters »Note: Use of this hook will require a manual reindex
By default SearchWP will index all Custom Fields (post meta) but with this hook you can selectively tell SearchWP to skip over any number of meta keys. To use this hook add something like the following to your theme’s functions.php
:
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 | |
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 ); |
Parameters
Parameter | Type | Description |
---|---|---|
$omit |
Boolean |
Whether the current meta record should be omitted from the index |
$meta_key |
String |
The |
$the_post |
Object |
The post object being indexed |