Skip Navigation

[Resolved] Display relationship field in elementor single template

This support ticket is created 5 years, 6 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by BDS 5 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#1371221

BDS

Hi,

I'm trying to create single post template for my website, the single post will include the information of it's parent relationship.

Eg: A real estate project features the information about it's project location and agent.

I went through the "real estate" Toolset template and learned how to setup, however the front-end using css to customize is frustrating, so I'm using Elementor single template instead. Everything was fine with Elementor dynamic field except I could not find a way to display the parent relationship in a single template.

Is there anyway to achieve this? Thank you

#1371267

Hi,

Thank you for contacting us and I'd be happy to assist.

There are a couple of ways you can achieve this:

1. Using the "item" attribute:

If you just need to show the data from a single or a few fields from the parent post, you can use the "item" attribute with the Types Fields API shortcodes ( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/ ) and the View's shortcodes ( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#displaying-data-2 ) which show an individual post's data.

https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/

Examples:

Assuming that on your website, these are the slugs for the parent, child and the post-relationship:

Parent post slug: project-location

Child post slug: real-estate

Relationship slug: project-location-real-estate

To get the value of the custom field with slug "example-field" from the parent post:


[types field="example-field" item="@project-location-real-estate.parent"][/types]

To get the title of the parent post, using the "wpv-post-title" shortcode:


[wpv-post-title item="@project-location-real-estate.parent"]

2. Using a post view:

If you'll need a collection of values from that parent post, it would be better to create a post view to show the related parent post's data and then call that view in your child post's template.

Here is a guide on the topic:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1377665

BDS

Exellent! Thank you so much!

Please feel free to mark my question as resolved