Skip Navigation

[Resolved] Viewing relationship data on a custom post type template page

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

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by barryG-4 3 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1857041
toolset-relationship.jpg

Tell us what you are trying to do?
Hi, I have a custom post type called Rentals for a real estate site. I have just made another custom post type called Employees.

On an Elementor > Templates > Theme Builder template page I’ve created for the Rentals custom post type, I’d like to display the following from a one (Employee) to many (Rentals) relationship:

a thumbnail image of the related Employee (the featured image)
name, phone number and email address (custom fields for the Employee custom post type).

So, I now have a Rental post related to an Employee. How do I retrieve the featured image and the three custom fields mentioned above from the related Employee and display them on the Rentals post page?

I thought I could create a 2 column container in Elementor and add an image element to the left hand column then select dynamic and a toolset relationship option then choose the featured image of the related employee as the data source and then the same for the three custom fields in the right hand column but I don't think that's possible or is it?

I’m attaching a screenshot. I’ve put in manually where I’d like the Employee data to go (ringed in red) so can you help please. I’ve got a feeling this is something to do with views but I don’t seem to have views on this site nor can I see it on the Toolset site anymore. I did see once that it was a legacy product so what can I do now please?

Many thanks,
Barry.

Is there any documentation that you are following? I've searched your support section but not found anything yet.

Is there a similar example that we can see? Not on any site that I've built.

What is the link to your site? hidden link which is a test domain I'm building the site on. An example of the page with the dummy employee data can be found here:

hidden link

#1857055
Screenshot-2020-11-25-at-19.04.58.jpg

Hi, miraculously I've found Views from somewhere within creating a content template. I don't know what I did but I've managed to solve most of the issue. I just don't get Blocks at all. Using them seems really clunky but that's probably because I'm so used to Elementor. Anyway, I'm persevering but how can I make the featured image slightly smaller and the text closer together please? I tried making a custom image size by editing the block relating to the image but an error occurred. I then tried to use the css option but the image disappeared completely and I had to quit the page without saving to get things back to how they were. I'd like to vertically centre align the three text fields also so they line up as a group in the middle of the image like the dummy example above. Is it possible to have your help getting this first view done then I think I will be able to do any others by myself.

Many thanks,
Barry.

#1857101

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Barry,

Happy to see that you've made progress with displaying your relationship data on your post template.

Would you mind allowing me to have admin access to the site so that I can assist with the code to get this working properly for you ?

I've enabled the private fields for your next response.

Thanks,
Shane

#1857595

Hi Shane, in addition to the above private message, I've just notice that by editing one Rentals post and connecting one employee to it, the same employee becomes connected to all rental posts. I had intended to be able to select different employees for individual Rental posts. Have I set up my one to many relationship incorrectly?

Many thanks,
Barry.

#1857619

Hi Shane, I think the relationship mentioned above might be okay but can I check it with you? I've got three Rentals posts. I connected one employee for one and another employee for another and those posts display the correct employee but the third post, 89 The Grampians, doesn't have any employee connected but when viewed publicly the post shows an employee. It should show nothing shouldn't it if there's not been one connected to that individual post? I'd be grateful if you can check that I set everything up correctly.

Many thanks,
Barry.

#1857913

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Barry,

Can you send me a link to the page that is in your screenshots so that I can know exactly what i'm working with ?

Thanks,
Shane

#1857937

Hi Shane, here is one of the three posts: hidden link

If you go to the home page and scroll down to the Featured Rentals section you can see the three in that row and click through to any of them. The template page for rentals is an Elementor Theme Builder template.

I'm trying hard not to use Elementor, but to use Blocks instead to build things after my last support query with you last week. I've made a Toolset Content Template for the Sales posts to compare and although it's nearly as good as the Rentals template I did in Elementor, I see lots of spaces between text and with simple things like using the 'before' option after adding a shortcode in Elementor for the Rentals price field so I can see the British pound sign, I can't see a 'before' option in the Block editor so there is no currency symbol on the Toolset Content Template page for Sales. It's these sort of things that are making me confused. I'm so close to getting it right but things look so much neater on the Rentals template. Anyway, any help you can give me is gratefully appreciated.

Many thanks, Barry.

#1857997

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-11-26 at 1.24.13 PM.png
Screenshot 2020-11-26 at 1.22.52 PM.png

Hi Barry,

On the view if you click on the text you can actually use the typography options to adjust the line height to reduce the space between each individual text on the page but you will need to adjust the line height for each item.

As you can see from my screenshot I managed to bold the number and email.

You can use these options to modify your typography.

Please let me know if this helps.
Thanks,
Shane

#1858093

Hi Shane, thank you for that. Is there anything that can be done to reduce the empty space at the bottom of the Toolset View that displays the staff image and the three fields? I can’t see anything obvious. I thought perhaps it might be a padding or margin setting but I don’t think there are any set by me that would do that so is there anything in any Toolset View code that would create the extra space? Many thanks, Barry.

#1858105

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-11-26 at 4.24.22 PM.png

Hi Barry,

Actually given that its in an elementor block you will need to adjust the margins and padding from the elementor template.

Based on my checks its because of the height of the container from elementor.

Using the elementor padding and margin settings should be able to resolve this one for you.

Thanks,
Shane

#1860371

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.