Custom WordPress robots.txt Without Plugins

Inspired by Modify the robots.txt file from wpvip.com

/**
 * Custom robots.txt
 */
if ( ! function_exists( 'custom_robotstxt' ) ) :
  function <meta charset="utf-8">custom_robotstxt() {
    echo "User-agent: MJ12bot" . PHP_EOL;
    echo "Disallow: /" . PHP_EOL;
  }
  add_action( 'do_robotstxt', '<meta charset="utf-8">custom_robotstxt' );
endif;

Leave a Reply

Your email address will not be published. Required fields are marked *