Created
December 21, 2020 13:25
-
-
Save andrasguseo/d653af9b1d9a9ac092c1e13bf29a5858 to your computer and use it in GitHub Desktop.
TEC: Excludes the event description and excerpt fields from the search
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 | |
/* Description: Excludes the event description and excerpt fields from the search. | |
* Usage: Paste the below snippet into your active (child) theme's functions.php file | |
* | |
* Plugin: The Events Calendar | |
* Author: Barry Hughes, Andras Guseo | |
* Last updated: 2020-12-21 | |
*/ | |
function modify_event_searches( $search, WP_Query $wp_query ) { | |
if ( empty( $search ) ) return; | |
global $wpdb; | |
$new_search = preg_replace( "/{$wpdb->posts}.post_(content|excerpt) LIKE ('[{}a-zA-Z0-9]+')/", "0", $search ); | |
return $new_search; | |
} | |
add_action( 'posts_search', 'modify_event_searches', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment