connect CPT student to CPT attendance

Support MB Relationships connect CPT student to CPT attendanceResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #20563
    RogerRoger
    Participant

    I 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.

    #20567
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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.

    #20570
    RogerRoger
    Participant

    oke. but what then? could you explain how i can create a list with the names in that posttype with the radio buttons behind it?

    #20572
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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/.

    #20574
    RogerRoger
    Participant

    Maybe 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?

    #20898
    Long NguyenLong Nguyen
    Moderator

    Relate to this topic https://support.metabox.io/topic/custom-field-that-works-with-mb_relationships-api/
    so I mark this topic as Resolved.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.