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 | |
function my_searchwp_max_search_terms( $maxTerms, $engine ) { | |
// limit to 5 search terms | |
return 5; | |
} | |
add_filter( 'searchwp_max_search_terms', 'my_searchwp_max_search_terms', 10, 2 ); |
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 | |
function my_searchwp_max_search_terms_supplemental( $maxTerms, $engine ) { | |
// limit to 7 search terms for all supplemental search engines, not the default | |
return 7; | |
} | |
add_filter( 'searchwp_max_search_terms_supplemental', 'my_searchwp_max_search_terms_supplemental', 10, 2 ); |
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 | |
function my_searchwp_max_search_terms_my_search_engine( $maxTerms ) { | |
// limit to 8 search terms for My Supplemental Search Engine ONLY | |
return 8; | |
} | |
add_filter( 'searchwp_max_search_terms_my_search_engine', 'my_searchwp_max_search_terms_my_search_engine', 10, 2 ); |
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 | |
function my_searchwp_index_chunk_size() { | |
// index 15 posts at a time instead of the default 10 | |
return 15; | |
} | |
add_filter( 'searchwp_index_chunk_size', 'my_searchwp_index_chunk_size' ); |
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 | |
// enable SearchWP debugging | |
add_filter( 'searchwp_debug', '__return_true' ); |
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 | |
function my_searchwp_engine_settings_default( $settings, $query ) { | |
// print_r( $query ); // uncomment this line to see the query structure | |
// if the visitor searched for soccer, boost the title weight a bit | |
if( in_array( 'soccer', $query ) ) { | |
// print_r( $settings ); // uncomment this line to see the settings structure | |
if( isset( $settings['post']['weights']['title'] ) ) { | |
$settings['post']['weights']['title'] = 15; | |
} |
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 | |
function my_searchwp_pre_search_terms( $terms, $engine ) { | |
if ( 'myengine' == $engine ) { | |
// do something with the terms | |
} | |
return $terms; | |
} | |
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 | |
function my_maybe_searchwp_load_posts( $loadPosts, $args ) { | |
// print_r( $args ); // uncomment this line to see the engine arguments | |
return false; // return only post IDs | |
} | |
add_filter( 'searchwp_load_posts', 'my_maybe_searchwp_load_posts', 10, 2 ); |
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 | |
add_filter( 'searchwp_index_attachments', '__return_false' ); |
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 | |
function my_searchwp_query_conditions( $sql, $postType, $engine ) { | |
// modify $sql to your liking | |
return $sql; | |
} | |
add_filter( 'searchwp_query_conditions', 'my_searchwp_query_conditions', 10, 3 ); |