Skip Navigation

[Résolu] Reuse Custom Field

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

Setup relationship between users and custom post types.

Solution:

For example, you can create a custom post type "Member":

https://toolset.com/forums/topic/reuse-custom-field/#post-1281463

Relevant Documentation:

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent

This support ticket is created Il y a 4 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.

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 2 réponses, has 2 voix.

Last updated by paulB-10 Il y a 4 années et 10 mois.

Assisted by: Luo Yang.

Auteur
Publications
#1281257

I have a number of custom fields that I want to use in a number of post types. e.g. a list of tournaments.
it can be used for player registration (post type) to nominate for a team and it can be used for nominating coaches and managers in another post type.
When you define a custom field you have to assign a CPT for it, otherwise, it is global. This does not work Great if you are trying to build up a hierarchy of fields, essentially an object.
e.g. A person's name is really first name + last name and you will always put them together so I would like to have a field
"Person Name" but not assign it to a post type in the custom field.
When I create a custom post type, create a custom field for the entire CPT e.g. Coach Nominations.
and create a Coach Nomination Custom field in which I would include person name.

See the following example.
CPT Coach Nominations
Custom Field -> Coach Nominations
includes Person Name (custom field) Not assigned to any post.
comprises First Name, Last Name

CPT Player Registrations
Custom Field -> Player Registration
includes Person Name (custom field) Not assigned to any post
comprises First Name, Last Name.

I have thought of creating a dummy CPT that comprises all custom fields but is just a holding object but I am sure there is a better solution.

Thank you in advance for your assistance and guidance.

#1281463

Hello,

In your case, I don't think there is other better solution.

For example, you can create a custom post type "Member", with custom fields
- Person Name
...

Setup one-to-many(or one-to-one) relationship between post type "Member" and "Coach Nominations",
In a single "Coach Nominations" post, you can display the related "Member" post information by above relationship, see our document:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent

#1281595

I will take on board the advice for future development of the website.
Thank you!

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