I would suggest you dynamically add CSS classes based on the post type the link points to.
Here are the steps to do it :
1- Add javascript something like :
jQuery(document).ready(function ($) {
$("a").each(function () {
var link = $(this);
var url = link.attr("href");
// Ensure it's an internal link
if (url && url.startsWith(window.location.origin)) {
$.ajax({
type: "POST",
url: ajaxData.ajaxurl,
data: {
action: "get_post_type",
url: url
},
success: function (response) {
if (response.type === "people") {
link.addClass("link-people");
} else if (response.type === "events") {
link.addClass("link-events");
}
}
});
}
});
});
2- Add ajax code in functions.php like this :
function get_post_type_by_url() {
if (isset($_POST['url'])) {
$post_id = url_to_postid($_POST['url']);
if ($post_id) {
$post_type = get_post_type($post_id);
wp_send_json(array('type' => $post_type));
}
}
wp_send_json(array('type' => ''));
}
add_action('wp_ajax_get_post_type', 'get_post_type_by_url');
add_action('wp_ajax_nopriv_get_post_type', 'get_post_type_by_url');
3- Add css
.link-people {
color: red !important;
}
.link-events {
color: green !important;
}