Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wordpress add sitemap.xml to robots.txt dynamically

/**
 * Add Yoast SEO sitemap to virtual robots.txt file network wide
 * https://wphelper.site/robots-txt-yoast-sitemap-multisite/
 */
function wphelper_network_robotstxt_function( $output, $public ) {
    $homeURL = get_home_url();
 
    $output .= "Sitemap: $homeURL/sitemap_index.xml
";
     
    return $output;
}
add_filter( 'robots_txt', 'wphelper_network_robotstxt_function', 20, 2 );
Source by wphelper.site #
 
PREVIOUS NEXT
Tagged: #wordpress #add #dynamically
ADD COMMENT
Topic
Name
9+2 =