Hello,
Thank you for contacting Rank Math, and sorry for any inconvenience caused.
Please add the following filter to your theme’s functions.php
to make the change to the homepage link:
/**
* Change the Home URL in breadcrumbs according to the current language in Polylang
*
* @param array $crumbs The crumbs array.
* @param Breadcrumbs $this Current breadcrumb object.
*/
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
// With this code, we get the home URL with the current language
$home_link = pll_home_url(pll_current_language());
// The first item in the $crumbs array is usually the home (except if it is disabled
// The second item inside each item is the link (so in this case, the home link)
$crumbs[0][1] = $home_link;
return $crumbs;
}, 10, 2);
Let us know if this code fixes the issue.
βββββββDon’t hesitate to get in touch if you require any further assistance.
Hi there, it fixed another issue I did not notice, the link, now it links properly to homepage in the language is viewed, but the displayed text is still wrong.
Hello,
Please try this code.
/**
* Change the Home URL in breadcrumbs according to the current language in Polylang
*
* @param array $crumbs The crumbs array.
* @param Breadcrumbs $this Current breadcrumb object.
*/
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
// With this code, we get the home URL with the current language
$home_link = pll_home_url(pll_current_language());
// The first item in the $crumbs array is usually the home (except if it is disabled
// The second item inside each item is the link (so in this case, the home link)
$crumbs[0][1] = $home_link;
$crumbs[0][0] = pll__("Home");
return $crumbs;
}, 10, 2);
I hope this helps. Looking forward to helping you.
yes and no, it says “home” for all languages, I can’t translate it.
LE: now it works o.O just did another reload of the page and it translates properly + links properly. thank you!
Hello,
Glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.