forked from LiveCarta/LiveCartaWP
@@ -175,9 +175,18 @@ function my_filter_post_where( $where) {
|
||||
if (!enableSearchQuery()) {
|
||||
return $where;
|
||||
}
|
||||
$parts = explode(' ', trim($_POST['search_text']));
|
||||
|
||||
$likeConditions = [];
|
||||
foreach($parts as $part){
|
||||
|
||||
$likeConditions [] = $wpdb->posts . '.post_title LIKE \'%' . trim(esc_sql( $part )) . '%\' ';
|
||||
$likeConditions [] = $wpdb->posts . '.post_content LIKE \'%' . trim(esc_sql( $part )) . '%\' ';
|
||||
|
||||
}
|
||||
|
||||
$where .= ' AND (
|
||||
' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( $_POST['search_text'] ) . '%\' OR
|
||||
' . $wpdb->posts . '.post_content LIKE \'%' . esc_sql( $_POST['search_text'] ) . '%\'
|
||||
'.implode(' OR ', $likeConditions) .'
|
||||
)';
|
||||
|
||||
return $where;
|
||||
|
||||
Reference in New Issue
Block a user