

add_filter( 'robots_txt', function ( $output, $public ) {
    if ( (string) $public === '0' ) {
        return $output;
    }

    $host = wp_parse_url( home_url(), PHP_URL_HOST );
    if ( empty( $host ) ) {
        return $output;
    }

    $output = (string) $output;

    // Eliminar bloque Yoast completo
    $output = preg_replace(
        '/#\s*START YOAST BLOCK.*?#\s*END YOAST BLOCK/is',
        '',
        $output
    );

    // Eliminar cualquier Sitemap residual
    $lines = preg_split( '/\r\n|\r|\n/', $output );
    $clean = array();
    foreach ( $lines as $line ) {
        if ( stripos( ltrim( $line ), 'Sitemap:' ) === 0 ) {
            continue;
        }
        $clean[] = $line;
    }

    while ( ! empty( $clean ) && trim( end( $clean ) ) === '' ) {
        array_pop( $clean );
    }

    $clean[] = '';
    $clean[] = 'Sitemap: https://' . $host . '/sitemap_index.xml';
    $clean[] = '';

    return implode( "\n", $clean );
}, 99999, 2 );
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//www.norttech.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://www.norttech.com/post-sitemap.xml</loc>
		<lastmod>2025-07-02T15:28:02+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.norttech.com/page-sitemap.xml</loc>
		<lastmod>2025-09-05T22:19:11+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.norttech.com/category-sitemap.xml</loc>
		<lastmod>2025-07-02T15:28:02+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.norttech.com/author-sitemap.xml</loc>
		<lastmod>2025-06-30T20:57:17+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->