I haven’t tested this but it SHOULD work. You’ll want to put it in the single-staff.php. You’ll have to add the details (actual query, post types, etc).
$reports = get_posts(array(
'post_type' => 'reports', //use actual post type
'meta_query' => array(
'relation' => 'or',
array(
'key' => 'primary_contact', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
array(
'key' => 'associated_contact', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
?>
<?php if( $reports ): ?>
<ul>
<?php foreach( $reports as $report ): ?>
<li>
<?php echo get_the_title( $doctor->ID ); ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>