Hi Martin,
If your goal is to save a "Handler" info with an individual dog, with respect to an individual event, you can add a new select type field to your "Events Dogs" relationship.
Step 1 screenshot: hidden link
hidden link
Step 2 screenshot: hidden link
hidden link
You can name this new "Select" field as "Dog Handler for the Event" and you don't need to add any options, as they'll be included programmatically.
Step 3 screenshot: hidden link
Next, to generate a list of all handlers for this new field, you can add the following code, at the bottom of your active theme's "functions.php" file:
add_filter( 'wpt_field_options', 'populate_dog_handler_select', 10, 3);
function populate_dog_handler_select( $options, $title, $type ){
switch( $title ){
case 'Dog Handler for the Event':
$options[] = array(
'#value' => '',
'#title' => '- Select -',
);
$args = array(
'post_type' => 'handler',
'posts_per_page' => -1,
'post_status' => 'publish'
);
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
Important note: Please make sure that the "Dog Handler for the Event" matches the title of this new field and the "handler" matches the slug of the "Handlers" post type.
As a result, when you'll be adding/connecting a dog with an event on the event's edit screen, you'll see this new field with a list of all available handlers to add to this entry.
Screenshot: hidden link
Note: this list will show all handlers and not the just the ones connected to the selected dog. To show only those handlers, which are connected to the selected dog, complex custom programming will be needed, which is beyond the scope of support that we can provide.
For more personalized assistance around custom code, you can always consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar