Last active
April 1, 2020 12:23
-
-
Save jchristopher/b303af4acd16b3397b005ca8e5c9fed0 to your computer and use it in GitHub Desktop.
Add 'extra' metadata to a SearchWP Entry
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 | |
// Customize a SearchWP Entry before it is indexed. | |
add_filter( 'searchwp\entry\data', function( $data, $entry ) { | |
// Use this key when adding a Custom Field Attribute. | |
$extra_meta_key = 'my_extra_meta'; | |
$value = 'This is extra data to index as extra meta'; | |
// SearchWP's Post Meta Attribute expects that data is made of Tokens. | |
$data['meta'][ $extra_meta_key ] = new \SearchWP\Tokens( $value ); | |
return $data; | |
}, 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment