[Résolu] Viewing relationship data on a custom post type template page
This support ticket is created Il y a 3 années et 10 mois. 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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
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? lien caché 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:
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.
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?
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.
Hi Shane, here is one of the three posts: lien caché
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.
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.
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.