This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 3.90 hours from now. Thank you for your understanding.

This topic contains 5 replies, has 6 voices, and was last updated by  davidB-41 3 years, 5 months ago. The support staff assigned to this topic is Bruno.

Author Posts
Author Posts
October 30, 2013 at 5:35 pm #284531


I just want to log this somewhere so that it can help others.

As of v1.4.19 of Yoast WordPress SEO plugin, the global constant of "WPSEO_FRONT_URL" has been removed. This is a critical piece to forming the correct url for the {sitemap.xsl} url on any generated {sitemap.xml} page.

Simple enough fix for the primary domain is to redefine the constant in some form in the active theme {functions.php} file. For example:

define('WPSEO_FRONT_URL', 'wpdir/wp-content/plugins/wordpress-seo/');

But that only gets part of the issue fixed. If your site uses multiple domains for the additional languages, you'll then need to open {plugins/sitepress-multilingual-cms/inc/wpseo-sitemaps-filter.php} and replace lines 130-147 with the following:

     * Filters XML sitemap stylesheet
    function set_stylesheet(){
    	global $sitepress_settings;

	    	$language_domain = $sitepress_settings['language_domains'][$this->get_sitemap_language()];
			$wpseo_dirname = str_replace('wp-seo.php', '', WPSEO_BASENAME);
			//$wpseo_domain_path = $language_domain . '/wp-content/plugins/' . $wpseo_dirname;

			/*$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="'.$wpseo_domain_path.'css/xml-sitemap.xsl"?>';*/
    		$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="'.$language_domain.'/'.WPSEO_FRONT_URL.'css/xml-sitemap.xsl"?>';
    	} else {
    		$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="'.WPSEO_FRONT_URL.'css/xml-sitemap.xsl"?>';

    	return $this->stylesheet;

This should keep everything in check. Hope this helps someone.

October 30, 2013 at 7:57 pm #284580

Forum moderator

Supporter languages: English (English ) Portuguese (Brazil) (Português )

Supporter Timezone: America/Sao_Paulo (GMT-03:00)

Dear Zach,

Thanks for sharing your code. It is truly appreciated.

Thank you.

December 18, 2013 at 9:19 am #310112


It doesn't fix the problem on my website... 🙁

hidden link

Please help !

February 26, 2014 at 6:52 pm #348111

Chitu Okoli

I had the same problem. Vincent: Do you still have the problem? Your sitemaps in English and Deutch seem to both be working OK.

I refactored Zach's code above to a much simpler situation for sites with multilingual domain names.

For this solution, the WPSEO_FRONT_URL definition in functions.php is completely unnecessary. Zach's solution is great, and better than mine if you only have one domain name for all languages. However, if you need to change WPML core files because you have multilingual domain names, then proceed:

In /plugins/sitepress-multilingual-cms/inc/wpseo-sitemaps-filter.php, completely replace function set_stylesheet() with this code:

    function set_stylesheet(){
    	global $sitepress_settings;
	$wpseo_path = wp_make_link_relative( plugins_url() ).'/wordpress-seo/'; // WP SEO plugin path without domain
	$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="'.$wpseo_path.'css/xml-sitemap.xsl"?>';

    	return $this->stylesheet;

That's it. This works for my multilingual domains.

However, I don't understand the "$wpseo_dirname = str_replace('wp-seo.php', '', WPSEO_BASENAME)" code in the original function, so there might be some setups where this code doesn't work.

It would be great if WPML could update the core with fixed code in response to Yoast's dropping of the WPSEO_FRONT_URL constant.

April 16, 2014 at 8:58 am #381621


Isn't it a bit strange that we need to "hack" the WPML code to get the sitemaps working?

Anyway, it seems like that the xsl isn't anymore in the plugin directory (..../css/xml-sitemap.xsl), but in the root: (at least at my wordpress install)?

This fixed the xsl error:

$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="'.home_url().'/main-sitemap.xsl"?>';
November 12, 2014 at 11:18 pm #510549


Hello and thanks for Zach's post.

Although this seems to be working OK for subdomain languages, but we have virtual directories for multi languages (eg. for english etc).

How can we solve this item?