Overview of the Issue
If your create your homepage in a different language than the site’s default language, you will notice that Rank Math SEO plugin sitemap incorrectly displays the actual slug of the page instead of just the language directory.
Workaround
This issue is fixed. Updating to the latest version solves it on your site, so you only need this workaround if you can’t update yet.
Please, make sure of having a full backup of your site before proceeding.
- Open …/wp-seo-multilingual/classes/RankMathSEO/Sitemap/Hooks.php file.
- Look for line 58.
- Change:
$this->secondaryHomesById = Maybe::fromNullable( get_option( 'page_on_front' ) ) ->map( PostTranslations::get() ) ->map( Fns::reject( Obj::prop( 'original' ) ) ) ->map( Fns::map( $getIdAndUrl ) ) ->map( Lst::fromPairs() ) ->getOrElse( [] ); - For
$this->secondaryHomesById = Maybe::fromNullable( get_option( 'page_on_front' ) ) ->map( PostTranslations::get() ) ->map( Fns::reject( \WPML\FP\Relation::propEq('language_code', apply_filters('wpml_default_language', 'en')) ) ) ->map( Fns::map( $getIdAndUrl ) ) ->map( Lst::fromPairs() ) ->getOrElse( [] );