Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Created March 16, 2022 16:48
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 searchwpgists/1870f2439f74f977bb95bb8149c34fd3 to your computer and use it in GitHub Desktop.
Save searchwpgists/1870f2439f74f977bb95bb8149c34fd3 to your computer and use it in GitHub Desktop.
Add additional content to Custom Field during indexing in SearchWP
<?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 . ' coffee';
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment