0

I managed to add an external sitemap to Yoast plugin and it works fine but i need to combine the following code in one simple code (.htaccess file)

RewriteRule ^\/?product-sitemap1\.xml$ /ext-sitemap/product-sitemap1.xml [L]
RewriteRule ^\/?product-sitemap2\.xml$ /ext-sitemap/product-sitemap2.xml [L]
RewriteRule ^\/?product-sitemap3\.xml$ /ext-sitemap/product-sitemap3.xml [L]
RewriteRule ^\/?product-sitemap4\.xml$ /ext-sitemap/product-sitemap4.xml [L]
RewriteRule ^\/?product-sitemap5\.xml$ /ext-sitemap/product-sitemap5.xml [L]
RewriteRule ^\/?product-sitemap6\.xml$ /ext-sitemap/product-sitemap6.xml [L]

function.php file

    add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false'); 
    add_filter( 'wpseo_sitemap_index', 'add_sitemap_custom_items' ); 

function add_sitemap_custom_items() {
    $sitemap_custom_items = ' https://example.com/product-sitemap1.xml 2019-01-18T00:12:27+00:00 ';

    $sitemap_custom_items .= ' https://example.com/product-sitemap2.xml 2019-01-18T00:12:27+00:00 ';

    $sitemap_custom_items .= ' https://example.com/product-sitemap3.xml 2019-01-18T00:12:27+00:00 ';

    $sitemap_custom_items .= ' https://example.com/product-sitemap4.xml 2019-01-18T00:12:27+00:00 ';

    $sitemap_custom_items .= ' https://example.com/product-sitemap5.xml 2019-01-18T00:12:27+00:00 ';

    $sitemap_custom_items .= ' https://example.com/product-sitemap6.xml 2019-01-18T00:12:27+00:00 ';

    return $sitemap_custom_items; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.