Here is my array which I am trying to get "apple" keyword in post table but it can't work like I want. Please let me know what is wrong with my array?
Array
(
[paged] => 1
[posts_per_page] => 50
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => product_type
[field] => slug
[terms] => Array
(
[0] => chipin
)
[operator] => NOT IN
)
)
[status] => publish
[orderby] => date
[order] => DESC
[meta_query] => Array
(
[0] => Array
(
[key] => _stock_status
[value] => instock
)
[1] => Array
(
[key] => post_title
[value] => apple
[compare] => LIKE
)
[2] => Array
(
[relation] => OR
)
)
[title_filter] => apple
[title_filter_relation] => OR
[post_type] => product
)
Here is query
SELECT SQL_CALC_FOUND_ROWS bhs_posts.ID
FROM bhs_posts INNER JOIN bhs_postmeta ON ( bhs_posts.ID = bhs_postmeta.post_id ) INNER JOIN bhs_postmeta AS mt1 ON ( bhs_posts.ID = mt1.post_id )
WHERE 1=1 AND (
bhs_posts.ID NOT IN (
SELECT object_id
FROM bhs_term_relationships
WHERE term_taxonomy_id IN (918)
)
) AND (
( bhs_postmeta.meta_key = '_stock_status' AND bhs_postmeta.meta_value = 'instock' )
AND
( mt1.meta_key = 'post_title' AND mt1.meta_value LIKE '{c914ad731b1921eeb5b858d7b618d23619ec92314bf850d67e343f6599dee9cc}apple{c914ad731b1921eeb5b858d7b618d23619ec92314bf850d67e343f6599dee9cc}' )
) AND ((bhs_posts.post_type = 'product' AND (bhs_posts.post_status = 'publish')))
GROUP BY bhs_posts.ID
ORDER BY bhs_posts.post_date DESC
LIMIT 0, 50
Database table:
If I can make query like following then get proper result but I don't know how to change array in Wp
SELECT SQL_CALC_FOUND_ROWS bhs_posts.ID
FROM bhs_posts INNER JOIN bhs_postmeta ON ( bhs_posts.ID = bhs_postmeta.post_id ) INNER JOIN bhs_postmeta AS mt1 ON ( bhs_posts.ID = mt1.post_id )
WHERE 1=1 AND (
bhs_posts.ID NOT IN (
SELECT object_id
FROM bhs_term_relationships
WHERE term_taxonomy_id IN (918)
)
) AND (
( bhs_postmeta.meta_key = '_stock_status' AND bhs_postmeta.meta_value = 'instock' )
AND
( bhs_posts.post_title LIKE 'apple%' )
) AND ((bhs_posts.post_type = 'product' AND (bhs_posts.post_status = 'publish')))
GROUP BY bhs_posts.ID
ORDER BY bhs_posts.post_date DESC
LIMIT 0, 50