WPML

Overview of the Issue

A fatal error occurs when using the HTML sitemap feature from the Rank Math SEO plugin via a shortcode, [rank_math_html_sitemap].

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in .../wp-content/plugins/wp-seo-multilingual/classes/RankMathSEO/Sitemap/Hooks.php on line 69

Workaround

This issue is fixed in WPML SEO 2.1.1. Updating solves it on your site, so you only need this workaround if you can’t update yet.

Please, make sure of having a full site backup of your site before proceeding.

  • Edit …/wp-content/plugins/wp-seo-multilingual/classes/RankMathSEO/Sitemap/Hooks.php file.
  • Just before line 66:
    PHP
    return Obj::assoc(
    	'loc',
    	Obj::propOr(
    		$url['loc'],
    		(int) Obj::prop( 'ID', $object ),
    		$this->secondaryHomesById
    	),
    	$url
    );
  • Add this code:
    PHP
    if (!is_array($url)){
    	$test = $url;
    	$url = array();
    	$url['loc'] = $test;
    }

All known issues

Still Seeing This Issue?

If updating doesn’t fix it, ask a support question and we’ll look into it with you.