Available since: 1.6
searchwp_excluded_custom_fields
View Parameters »By default, SearchWP excludes Custom Fields used by WordPress core to store data that is rarely (if ever) useful during searches. If you would like to modify the array of meta_key
s that are excluded when indexing, use this filter.
Example: To modify the meta_key
s excluded from the SearchWP index, add the following to your active 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_excluded_custom_fields( $keys ) { | |
// by default _wp_page_template is excluded but we want to include that | |
// so we'll return everything else we want excluded | |
$keys = array( | |
'_edit_lock', | |
'_edit_last', | |
'_wp_old_slug', | |
); | |
return $keys; | |
} | |
add_filter( 'searchwp_excluded_custom_fields', 'my_searchwp_excluded_custom_fields' ); |
Parameters
Parameter | Type | Description |
---|---|---|
$keys |
Array |
The default keys that are excluded by the indexer ( ‘_edit_lock’, ‘_wp_page_template’, ‘_edit_last’, ‘_wp_old_slug’ ) |