Custom Fields
Support MB Relationships connect CPT student to CPT attendance

  • Creator
  • #20563
    Resolved Roger

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
  • #20567
    Long Nguyen


    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

    For more information, please follow the basic usage and the syntax.


    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?

    Long Nguyen


    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


    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?

    Long Nguyen

    Relate to this topic
    so I mark this topic as Resolved.

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