WP Query search filter using get native php function or post method from input field for advance search from post and custom post type.
<?php
function title_filter($where, &$wp_query){
global $wpdb;
if($search_term = $wp_query->get( 'search_prod_title' )){
/*using the esc_like() in here instead of other esc_sql()*/
$search_term = $wpdb->esc_like($search_term);
$search_term = ' \'%' . $search_term . '%\'';
$where .= ' AND ' . $wpdb->posts . '.post_title LIKE '.$search_term;
}
return $where;
}
$args = array(
'post_type' => 'post',
's' => $search_terms,
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC'
);
$wp_query = new WP_Query($args);
?>
Reference:
WordPress The Loop Fetch Data From Database WP_Query/PHP
By Ashan Jay