Skip Navigation

[Resolved] How to display fields of related posts?

This thread is resolved. Here is a description of the problem and solution.

Problem:
With a post relationship between two post types, how to display a field from one post when viewing the other post.

Solution:
If there is just one connected post then when inserting a field using the Fields and Views button you will see a Post selection tab, where you can specify which post should be the source of the field, e.g. a related post.

If there may be more than one connected post, you would need to create a View to show posts related to the current one and add the field in the output section of the View.

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by Ben 6 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1089715

Ben

I have set up a Relationship between groups of Custom Post Types within Toolset. Say this relationship links CPT's Author to Title. When I am creating a 'Title', I have the option to edit data for my Custom Fields that I have already set up for this type. I can also connect an Author.

When designing the content on the page I want to be able to display the data from the Custom Fields, but also the connected post to. (in this case the connected Author).

I can see options everywhere to insert the Custom Fields, but I cannot find the option to insert the connected posts. Is there a way of doing this?

Thank you kindly in advance.

Ben

#1090161

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Ben

If there is only one Author connected to the Title then in your template for Titles it is straightforward to display fields from the connected Author.

When you use the Fields and View button to insert a field, you will see there is a post selection tab, where you can specify which post should act as the source of the field (so that instead of displaying the post title of the Title you can choose to display the title of the connected Author, for example).

If you have multiple Authors connected to the Title that would only output the field from one of the connected Authors, not all of them.

In that case you would need to create a View to query Authors which included a Query Filter to only show Authors connected to the current Title, and then in the output section you would show whichever Author fields you require.

Let me know if you need any more details.

#1091831

Ben

Thanks for your help Nigel.

In this instance there will be only one author, so I could accomplish it the first way.

But I am currently setting up Templates for different post types, and anticipate that in the future there may be cases where there is more than one author that needs to be displayed. In situations like this I am better to set up a View to "future proof" aren't I?

#1092881

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yes, effectively.

You could either cross that bridge when you come to it, and update the templates where you output the single author to use to a View to output multiple authors instead, or you could set it up like that now in any case. No harm in doing that even if all titles currently only connect to a single author.

#1093640

Ben

Thank you for your help Nigel!

Really appreciated.