Created
February 18, 2013 18:48
-
-
Save mbijon/4979627 to your computer and use it in GitHub Desktop.
WordPress posts_search filter example, for Tom Barrett on WP-Hackers list 2013-02-18
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
function tcb_filter_search( $term ) { | |
if ( is_search() ) | |
$search = "(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; | |
return $search; | |
} | |
add_filter( 'posts_search', 'tcb_filter_search', null, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why are you not escaping the term?