I think you can to use
- a CPT "Meetings" where each post is a meeting, you can handle hundreds or thousands with no problem
- a Custom Taxonomy "Meetings Type", in this way you can set types for meeting posts. Just like categories for standard posts.
- a CPT "Attendees" where each post is an attendee. Being posts you can handle hundrends or even thousands of them.
Of course the problem is how to connect "Attendees" with "Meetings", because WordPress doesn't have a way to connect a post type to another one.
First solution: Posts 2 Posts plugin
For this problem a popular solution would be use the Posts 2 Posts plugin.
It's a well known plugin, used by tons of people, and even its main author, Scribu, says he no longer supports it, from time to time it gets some commits on GitHub.
If you don't want to use that plugin there are some other solutions, I'll propose one here.
Alternative solution: private taxonomy
WordPress, by default, handles only one kind of many-to-many relation, its the one that is established between posts and taxonomies: you can use that to build your system.
What I suggest is to create an hidden taxonomy, called something like 'meeting_attendees'.
You should register that taxonomy with 'public'
argument set to false, something like:
register_taxonomy(
'meeting_attendees',
array('meetings', 'attendees'), // both CPTs will support the taxonomy
array('public'=>false)
);
In this way the taxonomy is registered, but it is hidden from WordPress admin UI.
After that, you should create a term for every meeting post. That can be done using 'save_post'
hook. Something like:
add_action ('save_post', function($post_ID, $post, $is_update) {
if ($post->post_type !== 'meetings' || $is_update) {
return;
}
wp_create_term('meeting-'.$post_ID, 'meeting_attendees');
}, 10, 3);
Than you need to build a metabox that allows you to select Attendee posts from Meeting post creation screen.
On Meeting save/update you have to assign to every selected attendee the same term created for the meeting.
In this way, having a meeting post, you can get the related 'meeting_attendees' taxonomy term with a simple get_the_terms
call and so be able to retrieve meeting attendees looking for attendees posts that have that term attached. Something like:
// assuming $meeting_id is the ID of Meetings post you want to get the Attendees for
$meeting_attendees = get_the_terms('meeting_attendees', $meeting_id);
if ( ! empty($meeting_attendees) && ! is_wp_error($meeting_attendees) ) {
$meeting_attendees_term = reset($meeting_attendees);
$attendees = get_posts(array(
'post_type' => 'attendees'
'tax_query' => array(
array(
'taxonomy' => 'meeting_attendees',
'terms' => array($meeting_attendees_term->term_id)
)
)
));
}
In the same way you can retreive all Meetings any Attendee attended:
// assuming $attendee_id is the ID of Attendee post you want to get attended meetings
$meeting_attendees = get_the_terms('meeting_attendees', $attendee_id);
if ( ! empty($meeting_attendees) && ! is_wp_error($meeting_attendees) ) {
$meetings = get_posts(array(
'post_type' => 'meetings'
'tax_query' => array(
array(
'taxonomy' => 'meeting_attendees',
'terms' => wp_list_pluck($meeting_attendees, 'term_id')
)
)
));
}
As you can see, using core methods is possible to get Attendee for a Meeting and Meetings for an Attendee in a pretty easy way.
The only effort needed is to create metabox that let you assign attendees to a meeting, but it should be pretty easy and if you need help you can find a lot of examples in this site, and all over the web... (e.g. the example on Codex for add_meta_box
function is pretty exahustive.