connect CPT student to CPT attendance
Support › MB Relationships › connect CPT student to CPT attendanceResolved
- This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by
Long Nguyen.
-
AuthorPosts
-
June 30, 2020 at 11:51 PM #20563
Roger
ParticipantI don't really understand how to do this with a relationship or maybe i'm thinking in the wrong direction.
I have a custom post type "leerling (student)". I also have a custom post type "Attendance".When I click new at Attendance I want to be able to select a date and see a list with the names from the students (that is loaded from the other Custom Post Type (This custom post type has the name "leerling (student)") and behind there name 2 radio buttons (or maybe 3, one with late when a child enters late) "Present" and "Absent".
Each student is also in a certain group. The groups are created with Taxonomies. Can these also be displayed here and that it is sorted on that?
I just can't figure it out, how can i transfer the post titles from the "leerling (student)" post type to the "Attendance" post type and create a list off it.
I don't know what to do anymore.July 1, 2020 at 9:50 AM #20567Long Nguyen
ModeratorHi,
You can use the sample code to create a relationship between to post types.
add_action( 'mb_relationships_init', function() { MB_Relationships_API::register( [ 'id' => 'attendance_leerling', 'from' => 'attendance', 'to' => 'leerling', ] ); } );
A meta box will be shown in each post of post type Attendance and you can connect to other posts of post type Leerling with the list post title. See my sample screenshot https://share.getcloudapp.com/wbuWXdRZ.
For more information, please follow the basic usage and the syntax.
July 1, 2020 at 3:53 PM #20570Roger
Participantoke. but what then? could you explain how i can create a list with the names in that posttype with the radio buttons behind it?
July 1, 2020 at 4:38 PM #20572Long Nguyen
ModeratorHi,
The relationship creates a different meta box and it does not show in a field group with other fields. I think you can use the field
post
to show the list post type, for more information, please follow this documentation https://docs.metabox.io/fields/post/.July 1, 2020 at 5:25 PM #20574Roger
ParticipantMaybe it's just me but do you understand my question? I can read the documentation a zilion times it still does not make any sense how i can get this to work.
You think i can use the field post... oke so i will write post in the function.php at the relation setting. that will not do the trick!
Meta box is advertising with we got your back. No php knowledge is needed.
I just want to keep track of the attendance from children! @ahn? please?July 22, 2020 at 10:37 AM #20898Long Nguyen
ModeratorRelate to this topic https://support.metabox.io/topic/custom-field-that-works-with-mb_relationships-api/
so I mark this topic as Resolved. -
AuthorPosts
- You must be logged in to reply to this topic.