Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Created March 16, 2022 16:44
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/0effac9dfd861181e02e6e941a5946bf to your computer and use it in GitHub Desktop.
Save searchwpgists/0effac9dfd861181e02e6e941a5946bf to your computer and use it in GitHub Desktop.
Add additional content to post during indexing in SearchWP
<?php
// Add additional content to post during indexing in SearchWP.
add_filter( 'searchwp\source\post\attributes\content', function( $content, $args ) {
if ( 48 !== $args['post']->ID ) {
return $content;
}
// Add 'coffee" to the content for Page 48 so it can be searched.
$content .= ' coffee';
return $content;
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment