Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created July 9, 2015 23:30
Show Gist options
  • Save jchristopher/676652d094264a3e8853 to your computer and use it in GitHub Desktop.
Save jchristopher/676652d094264a3e8853 to your computer and use it in GitHub Desktop.
<?php
// find out if there was an exact match
global $wpdb;
if ( defined( 'SEARCHWP_DBPREFIX' ) && SEARCHWP_DBPREFIX ) {
$searchwp_terms_table = $wpdb->prefix . SEARCHWP_DBPREFIX . 'terms';
$search_query = sanitize_text_field( get_search_query() );
$search_sql = "SELECT id FROM {$searchwp_terms_table} WHERE term = %s";
$term_found = $wpdb->get_var( $wpdb->prepare( $search_sql, $search_query ) );
$exact_match = is_null( $term_found ) ? false : true;
if ( $exact_match ) {
echo 'Exact match!';
} else {
echo 'NOT exact match!';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment