I’m having a problem: I’m trying to display content from a Custom Post Type post into a Landing Page using the relationship field.
This is the setup:
– there is a CPT called “movie” that has a lot of custom fields (director, year, actors etc).
– from time to time I need to create a landing page about a movie with more info (galleries, CTA, custom color combination) so I’ve some custom fields for this kind of template.
I don’t understand how can I use the relationship field to have the Landing Page populated with all the info from the selected movie. In this way I could use the Moive content as “main database” and add a landing only if/when needed with the ability to add all sort of editorial content.
when you set up the relationship field it either returns post objects (for your cpt) or post ID values. All you need to do to get custom fields from the related post is to either use setup_postdata() as explained on the page I linked to or supply the post ID when getting the field value, something like get_field('my_acf_field_name', $post->ID)`
If your relationship field allows more than one value then it will return an array of ID’s and if you are only returning the IDs then you don’t need $post-> you only use this when using setup_postdata()`