forked from LiveCarta/LiveCartaWP
LAW-2641
This commit is contained in:
@@ -175,9 +175,18 @@ function my_filter_post_where( $where) {
|
|||||||
if (!enableSearchQuery()) {
|
if (!enableSearchQuery()) {
|
||||||
return $where;
|
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 (
|
$where .= ' AND (
|
||||||
' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( $_POST['search_text'] ) . '%\' OR
|
'.implode(' OR ', $likeConditions) .'
|
||||||
' . $wpdb->posts . '.post_content LIKE \'%' . esc_sql( $_POST['search_text'] ) . '%\'
|
|
||||||
)';
|
)';
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
|
|||||||
Reference in New Issue
Block a user