Fix breadcrumbs issue “homepage” with RankMath and Polylang

Fix breadcrumbs issue “homepage” with RankMath and Polylang

In this moment, there is some issue with Rank Math SEO plugin and Polylang multilanguage WordPress plugin. After clicking on another langugage, “homepage” breacrumb has not been translated. Here is script that can fix this issue (website is having english and serbian activated languages):

/* rank math polylang breadcrumbs fix */
add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
$home_link = pll_home_url(pll_current_language());
if (get_locale() == ‘en_GB’) {
    $crumbs[0][0] = pll__(“Home”);
} else { $crumbs[0][0] = pll__(“Почетна”); }
$crumbs[0][1] = $home_link;
return $crumbs;
}, 10, 2);
Twitter
Facebook
LinkedIn
Telegram
WhatsApp
Email