Created
April 17, 2015 19:14
-
-
Save dcavins/3787e4e56a7116b61532 to your computer and use it in GitHub Desktop.
Modify the search "WHERE" statement in WordPress
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
add_filter('posts_search', 'what_the_search', $priority = 10, $accepted_args = 2); | |
function what_the_search( $search, $query ){ | |
if ( $query->is_search ) { | |
$towrite = PHP_EOL . '$search: ' . print_r( $search, TRUE ); | |
// $search looks like: | |
// AND (((wp_posts.post_title LIKE '%walking%') OR (wp_posts.post_content LIKE '%walking%'))) AND (wp_posts.post_password = '') | |
$fp = fopen('what_the_search.txt', 'a'); | |
fwrite($fp, $towrite); | |
fclose($fp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment