Support

Account

Home Forums ACF PRO Flexible, Group and Relationship fields reverse query not working

Helping

Flexible, Group and Relationship fields reverse query not working

  • I am using flexible content, group and relationship fields.
    First is the flexible content field. Inside it is a group field which has two rows. Those two rows are relationship field and text field.

    I am trying to replicate how IMDb shows the cast real name and name of that actor in a particular movie. Flexible field help me add each row for each group field. Inside group, I have set relationship field to select individual cast and an text field to show his/her name for that movie.

    I easily managed to output the relationship field (here I used some php to output the actor image and title) and text field data in for that particular movie.

    But while trying to reverse the relationship field data to show movies he/she played in his/her page, I can’t do it. How should I enter the key value in array as simply entering the relationship field doesn’t output any loop post.

    I need help in this code:

    $actors = get_posts(array(
    							'post_type' => 'actor',
    							'meta_query' => array(
    								array(
    									'key' => '<strong>{relationship field here is not working}</strong>', // name of custom field
    									'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
    									'compare' => 'LIKE'
    								)
    							)
    						));

    I found some examples of similar issue with repeater field, but that didn’t help me solve my problem. Can someone please suggest what should I enter as key here {relationship field here is not working} in code above.

  • Querying a relationship in a flex field is the same as querying a relationship in a repeater. See this other recent topic https://support.advancedcustomfields.com/forums/topic/reverse-query-relationship-within-repeater/.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Flexible, Group and Relationship fields reverse query not working’ is closed to new replies.