add_action("template_redirect", function() {
$currentUrl = trailingslashit(strtok($_SERVER['REQUEST_URI'], "?"));
if ($currentUrl === "/book/author/") {
$authorId = array_key_exists("id", $_GET) ? (int)$_GET['id'] : null;
$author = !is_null($authorId) ? get_user_by("id", $authorId) : null;
if (empty($author)) {
global $wp_query;
$wp_query->set_404();
status_header(404);
get_template_part(404);
die();
}
}
});