Relational Field connecting 2 CPTs

Hi guys,

I have a CPT called Website Content that contains a field group called Homepage. Within homepage is a relationship field called Feature Services & Issues that is filtered by 2 CPTs (Services & Issues).

So the User can select Issues or Services that are to be featured on the homepage.

On the homepage I have a section where I want to pull the data from the selected Services or Issues to show on a slider.

For the section I have a query builder provider set to type "Website Content "

But I can’t work out how to pull the data from the CTPs that were selected in “Feature Services & Issues”.

Thanks,
Darren.

Hey Darren,

Thanks for reaching out!

We are also uncertain with your issue. That being said, we need to check and investigate the backend settings properly. To do that, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password
  • Page URL or layout builder name

You can find the Secure Note button at the bottom of your posts.

Thank you.

Hello @DesignMunky,

When I edit one of the Website Content custom posts, I do not see the relationship or the field group.

  • See the secure note below.

Thanks.

Hi Reunel,

Sorry, I 'd changed the name of the Website Content CPT and didn’t realise that ACF had reset all the Field groups to show on posts, not Website Content. Have fixed this up now and saved some relationship fields in Mainstream 1 Demo.

THanks
Darren.

Hey Darren,

The return format of the ACF Relationship field should be Post Object.

And you must properly set up your Looper. Kindly check your layout now.

Thanks.

Hey Reunel,

Thanks for that. Its definitely pulling in the correct posts now.

How do I pull in say the Image for 2 different CPT when the image has different key for each CPT?

Regards,
Darren.

Hello Darren,

Can you please send me the URLs of the two CPTs so that I can check the image fields? You can also check the fields if you add {{dc:looper:debug_consumer}} dynamic content. This should display the different field names that are returned by the looper.

Best Regards.

Hey Ruenel,

Here’s the URLs of 2 of the CPTs that are selected on the Website Content CPT.

https://design.healthysites.com.au/issue/issue-1/
https://design.healthysites.com.au/service/service-2-2/

I tried adding {{dc:looper:debug_consumer}} to the dynamic content fields but it wasn’t showing the name fields. Is that what you meant? Add the code to the dynamic entry field for each image?

Thanks,
Darren

Hello There,

Are you trying to display the image inserted for the _service_feature_image and _issue_hero_image ? Inside your Looper Consumer, you will have to insert two Image elements. One for the issue and the other for the service. You also need to add a condition to each Image element so that it will only display if it is the correct post type.

Best Regards.

Hi,

Yes, I’m trying to display the image for either _service_feature_image or _issue_hero_image depending on what posts were selected in the Website Content Post.

For the looper provider I have dynamic content: {{dc:acf:post_field field=“featured_services_&_issues”}}
Then for the issue consumer {{dc:looper:field key=“issue_hero_image”}} (condition post type = issue)

I will do the service image after I get the issue image right.

I noticed you were referring to the field as “_issue_hero_image” not “issue_hero_image”. Is that for any reason?

Darren.

Hey Darren,

I believe that my colleague mistyped "_" before the ACF name. On the other hand, after investigating your setup, I found out that you added a Looper Consumer inside your image element. You don’t need to do that because you already set up Looper Consumer in your Slider parent container which the image is part of the slider. That being said, I have adjusted the image element to display the proper images.

To display the issue image I use this dynamic code in the image element: {{dc:acf:post_field field="issue_hero_image"}} and for the services {{dc:acf:post_field field="service_feature_image"}}

I’ve also added a condition to the image on which custom post type they belong.

Hope that helps.

Hey Marc,

Fantastic - thank you! Really appreciate the help.

Cheers,
Darren.

Hey Darren,

You’re most welcome!

Hey Marc,

I have another issue that I can’t seem to resolve.

I have a nested repeater in both the Services & Issue CPTs that I’m trying to access.

For the Issue CPT for example, I’m using a column with an array provider with the key set to “issue_feature_bullet_list” (which is the key to the repeater Group). The conditions are Post Type is Issue and Provider Output is not empty. And I have the field within the column set to be {{dc:looper:item}}.

Again, I’m not sure where I’m going wrong…?

Thanks Darren.

Hey Darren,

Where can we find this looper for both the Services & Issue CPTs? Please provide us the URL so we can check it.

Thanks.

Hi Ruenel,

The URL is https://design.healthysites.com.au/cornerstone/edit/775
and as you’ll see below, I have a looper provider & consumer set for Service Points and Issue Popints

Hello Darren,

I have checked your Website Content custom post type, there are no featured_services_&_issues. You should be using {{dc:acf:post_field field="featured_services__issues"}} instead.

Cheers.

Hey Ruenel,

Thanks for that. I’m now pulling in all the content I want, except for the Service Points & Issue Points, both of which are repeaters within the Service & Issues groups.

For Services, I have a provider set to dynamic content: {{dc:looper:field key=“service_features_group”}} and field set to {{dc:looper:field key=“service_feature_bullet_point”}}

I just can’t work out what I’m doing wrong here…sorry, could you have a look one more time?

Thanks,
Darren.

Hello Darren,

I do not see those fields in the Website Content post type or in the Issues post type.

  • see the links in the secure note.

Thanks.

Hi Ruenel,

The fields don’t appear in the Website Content post type. They are only in the Issues and Services post types which are both linked to Website Content via that relationship field.

For Services, the repeater field is service_features_group and the field within the repeater is service_feature_bullet_point

Thanks

For Issues, the repeater field is issue_features_group and the field within the repeater is issue_feature_bullet_point