Breadcrumbs homepage label with language polylang

#87371
  • Resolved Ahmed Sa’eed
    Rank Math free

    Hi,
    I use Polylang for multilanguage and my breadcrumbs in the second language do not display name label correctly the URL change but not the label using 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());
            $home_label = 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][1] = $home_label;
    
    	return $crumbs;
    }, 10, 2);
    

    i don’t want to use css to fix it i need to make sure google reads it correctly if you can help
    thank you

    • This topic was modified 3 years, 7 months ago by Ahmed Sa'eed.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello,

    We just released an update that has been improved with some missing translation tests. Please upgrade the plugin on your site then clear your cache and hard refresh your browser.

    If the issue still persists, then we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Alberto
    Rank Math business

    Hello,

    In the code you shared, you are using the same function to get the URL and the label, is it as it should be?

    $home_link = pll_home_url(pll_current_language());
    $home_label = pll_home_url(pll_current_language());

    Looking forward to help you.

    i don’t understand i’m asking you this quastion

    Alberto
    Rank Math business

    Hello,

    I mean the code you added to get the URL and the label is the same so it is getting the same for both fields. I guess you should use another function from Polylang to get the label.

    Looking forward to help you.

    sorry i don’t know how to do this i tried everything i can do

    I got this code originally from another support ticket you provided

    Alberto
    Rank Math business

    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][1] = pll__("Home");
    
    	return $crumbs;
    }, 10, 2);

    Looking forward to help you.

    it works with a little modification,
    $crumbs[0][0] = pll__("Home");
    thank you Alberto very very much, u guys are awesome best support team ever

    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 (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post 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 10 replies - 1 through 10 (of 10 total)

The ticket ‘Breadcrumbs homepage label with language polylang’ is closed to new replies.