Skip to content

Instantly share code, notes, and snippets.

@Zodiac1978
Created August 10, 2023 14:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zodiac1978/bb9a7192363864c3e2a73f74e7300542 to your computer and use it in GitHub Desktop.
Save Zodiac1978/bb9a7192363864c3e2a73f74e7300542 to your computer and use it in GitHub Desktop.
Add line in robots.txt to disallow GPTBot. (WordPress plugin)
<?php
/**
* Plugin Name: Disallow GPTBot
* Description: Add line in robots.txt to disallow GPTBot.
* Plugin URI: https://torstenlandsiedel.de
* Version: 1.0
* Author: Torsten Landsiedel
* Author URI: http://torstenlandsiedel.de
* Licence: GPL 2
* License URI: http://opensource.org/licenses/GPL-2.0
*
* @package SEO/Must-Use
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly.
/**
* Add Disallow for GPTBot
* See: https://platform.openai.com/docs/gptbot
*
* @param string $output The robots.txt output.
* @return string The modified robots.txt output.
*/
function disallow_gptbot( $output ) {
$output .= "\nUser-agent: GPTBot\nDisallow: *\n";
return $output;
}
add_filter( 'robots_txt', 'disallow_gptbot', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment