A
A
Alexander Sinitsyn2016-01-09 21:04:20
WordPress
Alexander Sinitsyn, 2016-01-09 21:04:20

How to filter posts by ACF field with type "Relationship" via WP_Query?

There is an ACF towns-field of relationship type with a towns record type. How to make a selection of records in a set of cities that have, for example, Moscow?

$args = array(
  'post_type'  =>  'offers',
  'meta_query' => array(
    array(
      'key' 	=> 'towns-field',
      'value' => 'Москва',
      'compare' => 'IN',
    ),
  ),
);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2016-01-10
@a_u_sinitsin

Well, the basic query seems to be correct, but you don’t need to specify compare in your case, it should be = and it has such a default value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question