{"id":15598341,"date":"2022-04-28T05:15:30","date_gmt":"2022-04-28T05:15:30","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/multiple-meta-key-provide-wrong-result\/"},"modified":"2022-04-28T05:15:30","modified_gmt":"2022-04-28T05:15:30","slug":"multiple-meta-key-provide-wrong-result","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/multiple-meta-key-provide-wrong-result\/","title":{"rendered":"Multiple meta key provide wrong result"},"content":{"rendered":"<p>Hi,<br \/>\nI have a problem with multiple meta keys not working together. I have 100 posts and they have 1 meta key is price and 1 meta key is price type. in price we store prices and price type we store Fixed, Negotiable, ON Call. here the on call posts are not showing with the price filter. If user search by price range 100 to 500 then I need to show on call posts but not showing. The on call posts price field is blank. So how I show on call posts with price range. Here is the query<\/p>\n<p>$args = array(<br \/>\n        &#8216;s&#8217; =&gt; $title,<br \/>\n        &#8216;post_type&#8217; =&gt; &#8216;ad_post&#8217;,<br \/>\n        &#8216;post_status&#8217; =&gt; &#8216;publish&#8217;,<br \/>\n        &#8216;posts_per_page&#8217; =&gt; 100, \/\/New Custom Code<br \/>\n        &#8216;post__in&#8217; =&gt; (!empty($postArr))? $postArr : [],<br \/>\n        &#8216;tax_query&#8217; =&gt; array(<br \/>\n            $category,<br \/>\n            $ad_types,<br \/>\n        ),<br \/>\n        &#8216;meta_query&#8217; =&gt; [<br \/>\n            &#8216;relation&#8217; =&gt; &#8216;AND&#8217;,<br \/>\n            $price,<br \/>\n            $custom_search,<br \/>\n            [<br \/>\n                &#8216;relation&#8217; =&gt; &#8216;OR&#8217;,<br \/>\n                $priceType,<br \/>\n            ],<br \/>\n        ],<\/p>\n<p>        &#8216;order&#8217; =&gt; $order,<br \/>\n        &#8216;orderby&#8217; =&gt; $orderBy,<br \/>\n        &#8216;paged&#8217; =&gt; $paged,<br \/>\n    );<\/p>\n<p>   $price = array(<br \/>\n        &#8216;key&#8217; =&gt; &#8216;price&#8217;,<br \/>\n        &#8216;value&#8217; =&gt; array($_GET[&#8216;min_price&#8217;], $_GET[&#8216;max_price&#8217;]),<br \/>\n        &#8216;type&#8217; =&gt; &#8216;numeric&#8217;,<br \/>\n        &#8216;compare&#8217; =&gt; &#8216;BETWEEN&#8217;,<br \/>\n    );<\/p>\n<p>$priceType = array(<br \/>\n            &#8216;key&#8217; =&gt; &#8216;price_type&#8217;,<br \/>\n            &#8216;value&#8217;     =&gt; array(&#8216;Negotiable&#8217;,&#8217;Fixed&#8217;,&#8217;on_call&#8217;),<br \/>\n            &#8216;compare&#8217; =&gt; &#8216;IN&#8217;<br \/>\n        );<\/p>\n<p>I have also tax_query so all combination not working together.<br \/>\nSo I need to display on call post with price range filter. Always price filter remove price type filter.<br \/>\nWhich post have on call then in postmeta table has  price = blank and price_type = on_call<br \/>\nand which ad have price type = Fixed and price = 100 or some other value.<\/p>\n<p>Please help.<\/p>\n","protected":false},"template":"","class_list":["post-15598341","topic","type-topic","status-publish","hentry","topic-tag-meta-query"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15598341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15598341\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=15598341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}