searchwp\source\post\attributes\meta
Since: 4.0.0
Table of Contents
Manipulate Custom Field (postmeta) data before it is indexed.
See also searchwp\source\post\attributes\meta\${meta_key} for a single Custom Field.
Parameters
| Type | Parameter | Default | Since | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Mixed | $meta_value |
Custom Field value (after it has been run through searchwp\source\post\attributes\meta\${meta_key}) |
4.0.0 |
||||||||||||
| Array |
$args
|
4.0.0 |
|||||||||||||
Examples
All hooks should be added to your custom SearchWP Customizations Plugin.
Add additional content to Custom Field
| <?php | |
| // Add additional content to Custom Field during indexing in SearchWP. | |
| add_filter( 'searchwp\source\post\attributes\meta', function( $meta_value, $args ) { | |
| if ( 'my_custom_field_key' !== $args['meta_key'] ) { | |
| return $meta_value; | |
| } | |
| // Add 'coffee' to Custom Field value to make it searchable. | |
| return $meta_value[0] . ' coffee'; | |
| }, 20, 2 ); |

