function add_geolocation_to_donors($post_id) {
// Assuming you have latitude and longitude custom fields
$lat = get_field('latitude', $post_id);
$lng = get_field('longitude', $post_id);
// Save or update the location data in a way you can query it later
update_post_meta($post_id, '_donor_geolocation', array('lat' => $lat, 'lng' => $lng));
}
add_action('save_post', 'add_geolocation_to_donors');
function create_donor_post_type() {
register_post_type(‘donor’,
array(
‘labels’ => array(
‘name’ => __(‘Donors’),
‘singular_name’ => __(‘Donor’),
),
‘public’ => true,
‘has_archive’ => true,
‘supports’ => array(‘title’, ‘custom-fields’),
‘show_in_rest’ => true,
‘rewrite’ => array(‘slug’ => ‘donors’),
)
);
}
add_action(‘init’, ‘create_donor_post_type’);