ACF Relationship field - No data visible

I have two CPTs Aircraft and Operations. I have an ACF PRO relationship field on the aircraft CPT joining the Operations.

I’m trying to display the relationship field data on a layout called aircraft so users can see the Operation the aircraft took part in and then click on the operation name to display the operation post.

I think this should be possible but I can’t seem to get it to work, The closest I’ve managed is to get an array to display when I set the relationship field to Post ID instead of Post object. When it’ set to Post object I get nothing.

I have set the provider to Dynamic Content and the value {{dc:acf:term_field_setting field=“aircraft_operations”}} and the consumer to All and in the text field {{dc:acf:post_field field=“aircraft_operations”}} and I’ve also tried the following:

{{dc:acf:post_field field=“aircraft_operations”}} and {{dc:looper:field key=“aircraft_operations”}}.

Can you advise what am I doing wrong ? or if it’s even possible to get the relationship data using looper etc

https://31association.co.uk/sqn_aircraft/tornado-gr4/
the field should be below the research links at the bottom of the page, it currently has 3 operations linked in the acf pro field.

Hey @Kennyboy7,

Regretfully, it is unclear to me what you’re trying to achieve. We need to see your exact set up so we can provide a recommendation. Please give us the following info in a Secure Note

  • URL of the page where you display the ACF content
  • WordPress Login URL
  • Admin username and password

Because you said you had trouble with the Post Object, maybe you’re trying to nest ACF content? If so, maybe you can useful information in our tutorial video here about nesting ACF data.

Thanks.

hi @christian,

I’ve added a secure note with login details. The field I’m trying to display is not nested in the ACF content it’s a top level field. I’ve tried all sort of combinations etc to get the data to appear and have probably made right mess of the section with looper providers / consumers etc so fell free to add an new section.

To clarify, I have a 2 CPTs Aircraft and Operations, each are separate information in there own right but I wan to add (link) the information from certain Operations to certain Aircraft so I created a relationship field on the aircraft CPT which pulls in the Operations. I then want to display the Operation name and have it link to the operation information on the aircraft page. The aircraft page is in the layout area of Pro.

Thanks for looking at this for me.

Hey @Kennyboy7,

You will need to set the Relationship Field to Post ID in order to get the Operation Post ID. The ID can be used in a Query String Looper Provider.

image

image

image

So to recap, the Looper Structure is as follows:

  • Main Looper - Dynamic Content {{dc:acf:post_field field="aircraft_operations"}}
    – Sub Looper - Query String post_type=operations&posts_per_page=5&offset=0&ignore_sticky_posts=1&post__not_in%5B0%5D={{dc:looper:item}}. Learn how to setup a Query String in this thread.

Notice the {{dc:looper:item}} in the Sub Looper. That outputs the Operation Post ID. Looping that will display all Operations of an Aircraft.

Hope that helps.

Mega thanks for getting this to pull through some data, however it does quite work.

I have for example I have 4 different Operations selected for one aircraft type and I get a random selection of operations that is repeating randomly and missing out one of the selected Operations.


I tried changing the looper consumer from All to one and it only displays 3 instead of 4 of the selected operations.

Any ideas why ?

Hi @Kennyboy7,

It seems that the Looper Provider set to the parent row is the reason behind your issue, I have checked by disabling the Looper Provider and Looper Consumer of the Row 2 under Operations temporarily, which resolves your issue.

Tornado-GR4-31-Sqn-Association (2)

Thanks

Thanks that solved the issue.

Mega help as always from you guys at Themeco, cheers.

This can be closed as solved now, thank you

Glad we could help,

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.