Sauter la navigation

[Résolu] Add some terms fields to a radio custom field

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

Problem: I have a custom radio field with 3 options. I have more information for each option, saved in custom fields. I would like to display that information on the post.

Solution: Create a custom post type and add the custom fields to this new custom post type. Create 3 posts in this CPT and add the information to each post's custom fields. Then make the custom field values equal the 3 post IDs. Use the selected radio field value to display the custom fields.

[types field="number-of-beds" id="[types field='room' output='raw'][/types]"][/types]

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/

This support ticket is created Il y a 6 années et 2 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par Pat Il y a 6 années et 2 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1146486

Pat

Hello,

I have a radio field and with some options (room1, room2 and room3).

I would like to be able to display some info specific info to each room.
I have already started to use taxonomy for this, but only one choice is permitted on the room and taxonomy is not the right way for me.
Now, I'm using a radio field for rooms, but I dont know how to attach generic info (like room name, room floor ...)
The idea is to specify only once the room info and to be able to retrieve the right one thanks to the radio field.
Any idea?
Regards
Pat

#1146596

You could create a custom post type called "Rooms", then add a post for each room. Add custom fields to the Room post type to store the information you need, like number of beds, number of baths, and so on.

Then in the room radio field, the options should match the IDs for each Room post. So if your Room posts are:
Room 1 - ID 123
Room 2 - ID 234
Room 3 - ID 345

Then your radio field options should be:
Text: "Room 1"
Content: 123

Text "Room 2"
Content: 234

Text "Room 3"
Content 345

Then you can display information about the selected Room using Types field shortcodes. For example if your number of beds field has the slug "number-of-beds" and the radio field for room has the slug "room", then you can do something like this on the post that has the room radio field:

[types field="number-of-beds" id="[types field='room' output='raw'][/types]"][/types]
#1147012

Pat

Hi Christian,

Sounds good.
Thanks for the explanations.
Regards
Pat