Available since: 3.0
searchwp_term_highlight_occurrence
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:
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 | |
// Tell SearchWP to highlight the second occurrence, not the first. | |
add_filter( 'searchwp_term_highlight_occurrence', function( $occurrence, $args ) { | |
return 2; | |
}, 20, 2 ); |
Parameters
Parameter | Type | Description |
---|---|---|
$occurrence |
Integer |
Which occurrence to highlight |
$args |
Array |
|