Wrong language translation breadcrumb for FR

#1071809
  • Resolved Anthony
    Rank Math free

    Hello,

    I own a website with both english and french languages.

    I don’t understand why the home on the French breadcrumb is “Home”. It should be “Accueil” like it is written on Rank Math SEO setting.

    Here is an exemple of a page to see the wrong breadcrumb: https://naturosibo.com/contact/

    Thank you in advance for your help.
    Kind regards,

    Anthony ROGER

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    We apologize for the issue you are facing with the breadcrumb translation on your website. It seems that the breadcrumb for the French language is not displaying correctly as "Accueil" and is instead showing as "Home".

    To resolve this issue, you can add a filter to your theme’s rank-math.php file to ensure that the correct breadcrumb is displayed for translated pages. Here’s a code snippet you can use:

    // Fixes missing "Shop" breadcrumb in WPML translated store pages.
    if( function_exists( 'icl_object_id' ) ) {
        add_filter( 'rank_math/frontend/breadcrumb/items', 'wpmlsupp_8672_fix_wc_store_breadcrumbs', 10, 2 );
    }
    function wpmlsupp_8672_fix_wc_store_breadcrumbs( $crumbs, $class ) {
        if ( is_product() || is_product_category() || is_product_tag() ){
            $current_language = apply_filters( 'wpml_current_language', NULL );
            $default_language = apply_filters( 'wpml_default_language', NULL );
            if ($current_language !== $default_language) {
                $shop_page_id = wc_get_page_id( 'shop' );
                $shop_page    = get_post( $shop_page_id );
    
                $store_crumb = array (
                    '0' => get_the_title( $shop_page ),
                    '1' => get_permalink( $shop_page ),
                    'hide_in_schema' => ""
                );
                array_splice( $crumbs, 1, 0, array( $store_crumb ) );
            }
        }
        return $crumbs;
    }

    Please ensure to take a backup of your website’s file and database before making any changes to the code.

    If you continue to experience issues or need further assistance, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.

    Thank you for raising this concern!

    Sources:
    Multilingual SEO with Rank Math SEO & WPML » Rank Math

    Anthony
    Rank Math free

    Hello,

    Thank you for your answer.

    The thing is that I’m using Polylang (Free version) and I already have following snippet:

    * rank math polylang breadcrumbs fix */
    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) { $home_link = pll_home_url(pll_current_language()); $crumbs[0][0] = pll__(“Home”); $crumbs[0][1] = $home_link; return $crumbs; }, 10, 2);

    Is it possible to modify it to indicates “Home” only for EN pages?

    Regards,
    Anthony

    Hello,

    In this case, please try this filter to force the breadcrumbs to follow the language set in Polylang:

    add_filter( 'rank_math/frontend/breadcrumb/strings', function( $strings ) {
    
        $current_language = ''; // Polylang function to get current language.
        if (PLL()->curlang->slug === 'en') {
            $strings['home'] = 'Home';
        }
    
        if (PLL()->curlang->slug === 'fr') {
            $strings['home'] = 'Accueil';
        }
        return $strings;
    }, 100, 9);

    Here’s how you can add a filter/hook to your WordPress site:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Looking forward to helping you.

    Anthony
    Rank Math free

    Hi Reinelle,
    Thank you so much for your help.
    It works perfeclty 🙂

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review on TrustPilot:
    https://www.trustpilot.com/evaluate/www.rankmath.com

    about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Wrong language translation breadcrumb for FR’ is closed to new replies.