WP_Query's WHERE updated, but Search Results are not updated
I am pretty new to WordPress here, and I have seen the way to add condition into the query is by adding below inside functions.php:
add_filter('posts_where', 'add_where');
function add_where( $where ) {
global $wpdb;
$post_title = get_query_var( 'post_title', FALSE );
$where .= AND {$wpdb-prefix}posts.post_title LIKE '%$post_title%';
return $where;
}
For the record, I have added 'post_title' in the query vars as well.
So when I trigger the search and when I printed the query, it is actually showing the query like what I wanted, for example I want to find posts where the post title consist of 'vascular' :
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_author = 2 AND wp_posts.post_status = 'private') AND wp_posts.post_title LIKE '%vascular%' ORDER BY wp_posts.post_date DESC LIMIT 0, 10
However, the search result is showing all posts.
Here is the link for it: http://verztec-online.com/clients/annals/?s=post_title=vascular
I am not sure what am I missing here.
Topic posts-where Wordpress
Category Web