There’s nothing in the code; everything that can be done in the code is already there (nofollow, noindex, etc.). But the bots that are causing problems are largely AI crawlers, and they mostly ignore bot directions, causing these kinds of issues.
So yeah, pretty much robots.txt, server directives, and blocking IPs.
We just need the calendar to limit the viewable events such as from current day forward 365 days or something like that. No one needs to see beyond that.
I just did this….
If the current year is 2025 (can view all of 2024, 2025, 2026 but no other years.)
If the current year is 2026 (can view all of 2025, 2026, 2027 but no other years.)
You can adjust the years if needed for min / max it limits bots as well as humans but should help keep it from scanning all of your way old and way future events.
Add the following file to your wordpress:
wp-content/mu-plugins/calendar-year-guard.php
Paste:
<?php
/**
* Plugin Name: Calendar Year Guard
* Description: Blocks abusive My Calendar year crawling with dynamic rolling limits.
*/
add_action('template_redirect', function () {
// Only act if a year parameter exists
if (!isset($_GET['yr'])) {
return;
}
// Sanitize year
$yr = (int) $_GET['yr'];
if ($yr <= 0) {
return;
}
// Rolling window: last year → next 1 years
$current = (int) date('Y');
$min = $current - 1;
$max = $current + 1;
if ($yr < $min || $yr > $max) {
status_header(410); // "Gone" tells bots to stop forever
nocache_headers();
exit;
}
}, 1); // priority 1 = run as early as possible
-
This reply was modified 4 months, 3 weeks ago by
Tech01.