Note: You are viewing the documentation for Version 4View Version 3 Docs


Since: 4.0.0

Table of Contents

Customize post content prior to it being indexed.


Type Parameter Default Since
String $content Post content to be indexed 4.0.0
Array $args
Key Type Value
post \WP_Post The post being indexed


All hooks should be added to your custom SearchWP Customizations Plugin.

Add additional content to post during indexing

// 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 );

How to use this code

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP