Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Plugin name: Modification of robots.txt
* Version: 0.1.0
*/
/**
* Modify robots.txt for main site and english site
*
* @param $output
* @param $public
*
* @return string
*/
function fbn_custom_robots( $output, $public ) {
$site_id = get_current_blog_id();
if ( $site_id == 1 ) {
$output .= "Disallow: /agb-und-widerruf/n";
$output .= "Disallow: /mein-konto/n";
$output .= "Disallow: /warenkorb/n";
$output .= "Disallow: /impressum-und-datenschutz/n";
} elseif ( $site_id == 11 ) {
$output .= "Disallow: /account/n";
$output .= "Disallow: /cart/n";
$output .= "Disallow: /imprint/n";
$output .= "Disallow: /terms/n";
}
return $output;
}
add_filter( 'robots_txt', 'fbn_custom_robots', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.