This file contains hidden or 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_remove_searchwp_live_search_theme_css() { | |
| wp_dequeue_style( 'searchwp-live-search' ); | |
| } | |
| add_action( 'wp_enqueue_scripts', 'my_remove_searchwp_live_search_theme_css', 99 ); |
This file contains hidden or 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_dlm_cpt_dlm_download_args( $args ) { | |
| $args['exclude_from_search'] = false; | |
| return $args; | |
| } | |
| add_filter( 'dlm_cpt_dlm_download_args', 'my_dlm_cpt_dlm_download_args' ); |
This file contains hidden or 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
| // Adds additional processing for ACF field with the name my_acf_relationship_field | |
| function my_searchwp_acf_relationship_processor( $customFieldValue, $customFieldName, $thePost ){ | |
| $content_to_index = ''; | |
| if ( 'partner_filter' == $customFieldName ) { | |
| $partner_filter = $customFieldValue[0]; | |
| } | |
| preg_match( '/^layouts_\d+_post_type/i', $customFieldName, $matches ); | |
| if( 'post_type' == $customFieldName || ( ! empty( $matches ) && is_array( $customFieldValue ) && ! empty( $customFieldValue ) ) ){ | |
| $post_type = $customFieldValue[0]; |
This file contains hidden or 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 | |
| // Override SearchWP's "Did you mean?" output. | |
| class MySearchwpDidYouMean { | |
| private $args; | |
| function __construct() { | |
| // Prevent SearchWP's automatic "Did you mean?" output. | |
| add_filter( 'searchwp_auto_output_revised_search_query', '__return_false' ); | |
| // Grab the "Did you mean?" arguments to use later. |
This file contains hidden or 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 extra weight to specific post types | |
| add_filter( 'searchwp\query\mods', function( $mods ) { | |
| $source_extra_weight = [ | |
| \SearchWP\Utils::get_post_type_source_name( 'post') => 100000, | |
| \SearchWP\Utils::get_post_type_source_name( 'page') => 1000, | |
| ]; |
This file contains hidden or 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 | |
| // @link https://searchwp.com/documentation/knowledge-base/add-woocommerce-product-variations-to-products/ | |
| // When using SearchWP it's necessary to disable WooCommerce's insistance on | |
| // automatically redirecting to a single search result without showing the | |
| // search results page, when that happens this hook doesn't run! | |
| // Willing to bet this can be edited to accommodate, tips are welcome! | |
| add_filter( 'woocommerce_redirect_single_search_result', '__return_false' ); |
This file contains hidden or 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 process shortcodes | |
| add_filter( 'searchwp_do_shortcode', '__return_true' ); | |
| // if the SearchWP indexer is running prevent returning the | |
| // content between [searchwp_no_index] and [/searchwp_no_index] | |
| function shortcode_searchwp_no_index( $atts, $content = null ) { | |
| // if the searchwp_indexer_running action fired, the indexer is running so don't return anything | |
| return did_action( 'searchwp_indexer_running' ) ? '' : $content; |
This file contains hidden or 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 results to Posts and Pages. | |
| add_filter( 'searchwp\query\mods', function( $mods, $query ) { | |
| $mod = new \SearchWP\Mod(); | |
| $mod->set_where( [ [ | |
| 'column' => 'source', | |
| 'value' => [ | |
| \SearchWP\Utils::get_post_type_source_name( 'post' ), |
This file contains hidden or 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 | |
| // Randomize SearchWP search results. | |
| add_filter( 'searchwp\query\mods', function( $mods ) { | |
| $mod = new \SearchWP\Mod(); | |
| $mod->order_by( 'random', null, 1 ); | |
| $mods[] = $mod; | |
| return $mods; | |
| } ); |
This file contains hidden or 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 | |
| /** | |
| * Search results are contained within a div.searchwp-live-search-results | |
| * which you can style accordingly as you would any other element on your site | |
| * | |
| * Some base styles are output in wp_footer that do nothing but position the | |
| * results container and apply a default transition, you can disable that by | |
| * adding the following to your theme's functions.php: | |
| * | |
| * add_filter( 'searchwp_live_search_base_styles', '__return_false' ); |
OlderNewer