Assume, i have two custom post types - Project and Technology. Every project has a relation to Technology (using ACF). The question is - How to filter it by Technology. I tried this approach:

'post_type' => 'project',
'meta_query'    => array(
'relation' => 'AND',
        'key' => 'technology',
        'value' => $_GET['technology'],
        'compare' => 'LIKE',
        'key' => 'country',
        'value' => $_GET['country'],
        'compare' => 'LIKE',

But it works only for simple relations (like string, int or bool), but i doesn't work with object relations.

  • What is the common relation between the two post types? The same post meta? – Jami Gibbs Dec 26 '16 at 16:53
  • i don't understand your question((( i created custom post types with CTP UI, and connected those with ACF. – Alex Sanzharevskyy Dec 26 '16 at 18:01
  • How does ACF store relationship? This is probably something you will have to ask ACF support, as it is specific to that plugin. – Milo Dec 26 '16 at 18:29

Get the two post types along with their acf meta and use PHP Array Functions ( like Array Interset) to get the common/union or intersection. Additionally this will help you in this regards.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.