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


View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 3.0


View Parameters »

When highlighting is enabled, SearchWP will highlight the first occurrence of a match when generating an excerpt. If you’d like to modify which occurrence SearchWP uses to highlight, you can use this hook:

// Tell SearchWP to highlight the second occurrence, not the first.
add_filter( 'searchwp_term_highlight_occurrence', function( $occurrence, $args ) {
return 2;
}, 20, 2 );
view raw functions.php hosted with ❤ by GitHub


Parameter Type Description
$occurrence Integer

Which occurrence to highlight

$args Array

$args['query'] The search query

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