Created
June 30, 2020 00:18
-
-
Save jchristopher/4951b81c94724b1f62900bce0333bc69 to your computer and use it in GitHub Desktop.
Limit SearchWP Product searches to the first 30 characters of the Title
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 | |
// Limit SearchWP Product searches to the first 30 characters of the Title. | |
add_filter( 'searchwp\entry\data', function( $data, $entry ) { | |
$source = \SearchWP\Utils::get_post_type_source_name( 'product' ); | |
if ( $source === substr( $entry->get_source()->get_name(), 0, strlen( $source ) ) ) { | |
$data['title'] = isset( $data['title'] ) ? substr( $data['title'], 0, 30 ) : ''; | |
} | |
return $data; | |
}, 30, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment