Skip to content

Instantly share code, notes, and snippets.

Jon Christopher jchristopher

Block or report user

Report or block jchristopher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Pre-process Custom Field content before it is sent to SearchWP's highlighter
View functions.php
<?php
// Pre-process Custom Field content before it is sent to SearchWP's highlighter.
add_filter( 'searchwp_th_pre_process_meta_value', function( $meta_value, $meta_key, $post_id ) {
// TODO: Customize $meta_value in any way you see fit.
return $meta_value;
}, 20, 3 );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Pre-process content before it is sent to SearchWP's highlighter
View functions.php
<?php
// Pre-process content before it is sent to SearchWP's highlighter.
add_filter( 'searchwp_th_pre_process_content', function( $content ) {
// TODO: Customize $content in any way you see fit.
return $content;
} );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Customize the 'password protected' message returned by SearchWP's highlighter
View functions.php
<?php
// Customize the 'password protected' message returned by SearchWP's highlighter.
add_filter( 'searchwp_th_password_required_message', function( $message ) {
return __( 'There is no excerpt because this is a protected post.' );
} );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Tell SearchWP to use partial matches when highlighting
View functions.php
<?php
// Tell SearchWP to use partial matches when highlighting.
add_filter( 'searchwp_th_partial_matches', '__return_true' );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Control the length of excerpts generated with SearchWP's highlighter
View functions.php
<?php
// When highlighting, tell SearchWP to generate excerpts that are 75 words long.
add_filter( 'searchwp_th_num_words', function( $length ) {
return 75;
} );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Control which SearchWP engines receive highlights
View functions.php
<?php
add_filter( 'searchwp_th_excluded_engines', function( $engines ) {
// Prevent highlighting for 'supplemental' engine.
$engines[] = 'supplemental';
return $engines;
} );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Prevent SearchWP from expanding Shortcodes when highlighting
View functions.php
<?php
// Prevent SearchWP from expanding Shortcodes when highlighting.
add_filter( 'searchwp_th_do_shortcode', '__return_false' );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Prevent SearchWP from automatically highlighting content
View functions.php
<?php
// Prevent SearchWP from automatically highlighting content.
add_filter( 'searchwp_th_auto_highlight_content', '__return_false' );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Prevent SearchWP from automatically highlighting excerpts
View functions.php
<?php
// Prevent SearchWP from automatically highlighting excerpts.
add_filter( 'searchwp_th_auto_filter_excerpt', '__return_false' );
@jchristopher
jchristopher / functions.php
Last active Apr 26, 2019
Control which occurrence is used when SearchWP highlights results
View functions.php
<?php
// Tell SearchWP to highlight the second occurrence, not the first.
add_filter( 'searchwp_term_highlight_occurrence', function( $occurrence, $args ) {
return 2;
}, 20, 2 );
You can’t perform that action at this time.