Интересно, могу ли я задать вам вопрос.
Я хочу найти и получить сообщения, которые включают " test1 " или " test2 test3 ", используя get_posts()
функция.
это мой пример кода:
$a = new wp_query( array(
'post_type' => 'post',
'posts_per_page' => '6',
's' => 'test1,test2 test3',
) );
$query = $a->request;
значение переменной $query
будет:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}') OR (wp_posts.post_excerpt LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}') OR (wp_posts.post_content LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}')) AND ((wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}') OR (wp_posts.post_excerpt LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}') OR (wp_posts.post_content LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}')) AND ((wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}') OR (wp_posts.post_excerpt LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}') OR (wp_posts.post_content LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}'))) AND (wp_posts.post_password = '') AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending') ORDER BY (CASE WHEN wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1,test2 test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' THEN 1 WHEN wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' AND wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' AND wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' THEN 2 WHEN wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' OR wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' OR wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' THEN 3 WHEN wp_posts.post_excerpt LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1,test2 test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' THEN 4 WHEN wp_posts.post_content LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test1,test2 test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}' THEN 5 ELSE 6 END), wp_posts.post_date DESC LIMIT 0, 6
1- Почему%
символ знака изменился на {a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}
?
2 - он отделил test1
, test2
и test3
как независимые слова в результате запроса, но я хотел найти test2
иtest3
все вместе вот так:
(
(
wp_posts.post_title LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2 test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}'
) OR (
wp_posts.post_excerpt LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2 test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}'
) OR (
wp_posts.post_content LIKE '{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}test2 test3{a54b64746a8b39056d62c2b65ae46c2c408f25c890479d25ecf9719429cbd40b}'
)
)
Как это возможно?