How to add query string at the end of sitemap Yoast SEO

If you want to add ?wmc-currency=AUD for all of your product URLs in the sitemap, you can use the wpseo_xml_sitemap_post_url filter:

/**
 * Alters the URL structure for all products
 *
 * @param string  $url  The URL to modify.
 * @param WP_Post $post The post object.
 *
 * @return string The modified URL.
 */
function sitemap_product_url( $url, $post ) {
        if ( $post->post_type === 'product' ) {
                $url .= '?wmc-currency=AUD';
        }
        return $url;
}
add_filter( 'wpseo_xml_sitemap_post_url', 'sitemap_product_url', 10, 2 );

If you want to add extra URL for other currencies, you can then generate an additional sitemap, and then include that sitemap for indexing using the following code:

 * Writes additional/custom XML sitemap strings to the XML sitemap index.
 *
 * @param string $sitemap_custom_items XML describing one or more custom sitemaps.
 *
 * @return string The XML sitemap index with the additional XML.
 */
function add_sitemap_custom_items( $sitemap_custom_items ) {
    $sitemap_custom_items .= '
<sitemap>
<loc>http://www.example.com/external-sitemap-1.xml</loc>
<lastmod>2017-05-22T23:12:27+00:00</lastmod>
</sitemap>';
    return $sitemap_custom_items;
}

add_filter( 'wpseo_sitemap_index', 'add_sitemap_custom_items' );

Reference: Yoast SEO Sitemap API

tech