[Resolved] Problem when displaying multiple post types in a view.
This support ticket is created 2 years, 2 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I work on 3 custom post types: 1) Scientific Products, 2) Accessories and 3 Spare Parts & Consumables. I created 2 many to many relationships: 1) Scientific Products and Accessories and 2) Scientific Products Spare Parts & Consumables.
In the Scientific Product template, I want to display the related Spare Parts & Consumables and Accessories all together. So, I setup a view and enabled the multiple post types in a view. I add a filter to show only the post with a relationship with the current post. I use the Kadence infobox to present each related product. However, I can select from only one custom post type. The post title is displayed for both Accessories and Spare Parts & Consumables, but the image only from one of them. Please see the section named "Related Products".
By checking the support forum, I found a workaround. You can check the section "All related products" where I use the Toolset's Heading and Image blocks. I added 2 image blocks, one per custom connected type. Although it works, it requires a lot off time to create a similar aesthetic view as the Kadence Infobox. Do you have any suggestions on how to use the infobox to display multiple post types in a view? Should I add conditionals? Have in your mind that, eventually, I will have many connected post types.
You can check it here: hidden link
You already have an account on the website because I have another support ticket open.
Thank you for contacting us and I'd be happy to assist.
The challenge here is that your website is using different custom fields for images, in each post type. Although the field name "Image" is the same, the actual field slug is "spc-image" in the 'Spare Parts & Consumables' post type and "accessory-image" in the 'Accessories' post type.
While adding separate "Info Box" blocks for each post type inside the conditional block that checks for the post type can work, it can be cumbersome to maintain in the long run.
( due to repetition and an increasing number of connected post types )
A better alternative can be to use the same custom fields across the post types for the fields which you'll need in all of them. For instance, currently in the two custom field groups 'Field Group for Spare Parts & Consumables' and 'Field Group for Accessories,' you have two common purpose fields for image and short description, but with different slugs. You can include a common custom field group called something like 'Field Group for common fields' and set it to be attached to both 'Spare Parts & Consumables' and 'Accessories' post types. This way you won't have to set different "Info Box" blocks for each post type because the dynamic source custom fields would be the same.
I hope this helps and please let me know if you need any further assistance around this.
I have another related question. Is it possible to use the conditional block in order to check if there is any related product? And in that case, I will display the related products section. Otherwise, I will not display anything.