Skip Navigation

[Resolved] Display a custom field about CPTs in relationship

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.

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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 1 year, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2579269

Tell us what you are trying to do?
I'm trying to do an Online Menus site, where bar and restaurants can create their own profile and add their menus.
To project this I'm using Blocks addon.
I have created 3 different CPTs: Restaurants, Menus, and Allergens. Where Restaurants CPT has a one-to-many relationship with Menu CPT, and Menu CPT has many-to-many relationships with Allergens CPT.

I have created a Custom Template to show the Logo, Name, and description of the restaurants. In the footer, I have added a section where are showed the complete post list of the allergens CPT.

In the middle, I have added a View to show the Menu items related to the restaurant, and it works fine. In the View filter I have set this: Select posts in a Restaurants Menus relationship that are related to the Post where this View is shown.
When I add a Menu item it needs to be set the relationship, selecting the Related Main Restaurant (Is there a way to display the Menu Items without setting the Relationship manually? I think that it is possible to use the Author in relation to the CPTs posts, sure? But, to work perfectly, it needs to permit to create only one Restaurants CPTs post per Author, sure?)

Well, in the View where are shown the Menu Items, I need to display a Custom Field (number) about the related Allergens CPTs items, but I don't know how I can do that. Can you help me, please?

Is there any documentation that you are following? I haven't found anything about using Blocks for that use.

Is there a similar example that we can see? I don't know.

What is the link to your site? hidden link

#2579661

Hello,

Q1) When I add a Menu item it needs to be set the relationship, selecting the Related Main Restaurant (Is there a way to display the Menu Items without setting the Relationship manually?
It needs to connect the "Menu" with "Restaurant" posts manually, if you are using Toolset Forms plugin, in the parent "Restaurant" relationship field of post form for creating new "Menu" post, you can enable option "Get only options by the current author", so user can select only his own "Restaurant" posts.

See below test site:
Login URL:
hidden link

Post form:
hidden link

Q2) I need to display a Custom Field (number) about the related Allergens CPTs items, but I don't know how I can do that
How do you setup the Custom Field (number)? can you reproduce the same problem in above test site?

#2580305

Thank you for your reply about Q1.

Q2) In your sandbox site, I have created the Custom Field (Number) and added it to Allergens CPT. I have created 3 different Menus CPT posts, and I have added them to the related Allergens CPT posts. I have added the related Menus CPT posts to the Restaurants CPT post (Restaurant A).
In the Restaurant A post I have created the View to display the list of the Menus CPT posts, it displays only the title.
When I try to create a View to display the Custom Field (number) of the related Allergens CPT post, it returns me the message that it is not possible to create a nested View...
I don't know what I can do to display the related Allergens inside the Menu items in the Menus list in the Restaurants CPT posts...

#2581127

You can setup the child post view with legacy editor, the display it in the parent post view loop. see our document:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

#2581271

Hi,
thank you for your reply.
I have found another "solution" to do what I need.
Well, I have created a Checkboxes Custom Field and I have added all Allergens references.
Now when I create an item I can select the allergens from checkboxes and display them without any issues or other Views.

#2581927

Thanks for sharing the "solution", it will help other users.

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