acf custom types, relationship fields, and the rest api


I have two custom post types with a bidirectional relationship via acf fields. The fields are exposed to the rest_api and I can see the values doing queries but filtering results based on the field do not seem to work.

How can I, with the rest api, pull all posts of one type that are associated with a single instance of the 2nd type.

for example if the types were products and brands, get all the products belonging to a single brand.

where product has a relationship field pointing at brand.

Inside my filter_add_rest_post_query I currently have:

$params = $request->get_params();


    $args['meta_query'][] = array(
      'key' => 'brand',
      'value' => $params['brand'],
      'compare' => 'IN'

lathomas64 2 years 2022-03-20T13:20:54-05:00 0 Answers 0 views 0

Leave an answer