Polylang Compability

#439807
Viewing 15 replies - 1 through 15 (of 27 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with enabling Rank Math meta titles on archive pages translated with Polylang.

    The issue seems to only affect archive titles as the descriptions and the rest of your pages are being translated.

    Please verify that you have enabled the Rank Math metabox in category page editor. To do this, go to WordPress dashboard > Rank Math > Titles & Meta > Categories and make sure “Add SEO controls” is turned on.

    Is it related to that old sitemap issue or is it a bug?

    It is unlikely that this is related to sitemaps. If the above steps did not work, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    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.

    Hi Nigel, thank you very much for your reply.

    Actually, I know about the “Add SEO Controls” feature, that allows to write a custom SEO Title + Description for each Category / Tag, overwriting the default I can define in Rank Math plugin.

    However, Polylang text translation allows to set a default text for the other languages as well, translating that value saved on Rank Math. That way, when you create a new Tag / Category, WordPress uses those default values automatically (considering each language).

    So as you can see in this picture below, there is a default title + description set for the Tags’ archive:
    https://drive.google.com/file/d/1XL4BELcl4_5GrC9wXoJUiYwc1tofGTde/view

    However, you can check here that the Tags’ archive is not translated:
    https://nerybusiness.com/es/tag/marketing-digital-es

    Yes, I can solve it translating each tag manually using the “SEO Controls”, but it’s not right. By default, Rank Math should use the text set above (as well as other plugins, like Yoast, do).

    The same happens for a custom post archive:
    https://drive.google.com/file/d/1XN6X8XrneLDcvzcHmyjnX3O1xvgiKIiT/view

    As you can see, it’s archive is not translated as well:
    https://nerybusiness.com/es/content

    I’ve tried to explain everything in details, but if you need me to be more clear, let me know.

    Best

    Nigel
    Rank Math business

    Hello,

    Thank you for your patience as we look into your issue. Please may you contact Polylang support as the tag archive title and description translation issue seems to be coming from their integration with Rank Math.

    Hope that helps. Please let us know if you have questions.

    So Nigel, we have a problem, because I feel you guys don’t like each other…
    https://wordpress.org/support/topic/after-the-translation-the-page-was-not-included-in-the-xml-sitemap/

    By the way, before using Rank Math I’ve been using Yoast SEO with Polylang, and I never had any problem of text translation.

    So I really believe it is a Rank Math bug, not a Polylang’s…

    Thank you for understand, and looking forward to hearing you back.

    David
    Rank Math free

    Hi Gui,

    was having the same problem and figured to let you know about a workaround I found that’s working somewhat fine until RankMath and Polylang hopefully come up with a fix.

    Not sure how big the impact on performance is but I ended up translating the meta title & description by modifying the archive-[CPT].php file within the theme folder by using the hooks offered by RankMath:

    if (get_locale() == ‘[language code such as en_GB]’) {
    add_filter( ‘rank_math/frontend/title’, function( $title ) {
    $title = ‘[TITLE]’;
    return $title;
    });
    add_filter( ‘rank_math/frontend/description’, function( $description ) {
    $description = ‘[DESCRIPTION]’;
    return $description;
    });
    }

    By placing this at the top of your archive template the output for both the meta title and description are modified if that language is detected. Make sure to replace [language code such as en_GB], [TITLE] and [DESCRIPTION] with the according values you want to use. Hope this helps!

    Hi David, thank you very much for your message! 🙂

    Actually I’ll be waiting for Rank Math’s solution because it’s clearly a bug. I’m sure because, for example, in Polylang’s text translation there is a field for the Tags, but not for the Categories. And this makes no sense.

    In Yoast everything always worked fine. I’ve changed to Rank Math mainly because of the Content AI…

    But again, thank you!
    Best

    Nigel
    Rank Math business

    Hello,

    Thanks @David for the tip it gave us some direction.

    Please try the following code snippet which should dynamically generate the correctly translated default titles for you:

    
    foreach (pll_languages_list( ['fields' =>'locale'] ) as $current_locale){
    if (get_locale() == $current_locale) {
    	add_filter( 'rank_math/frontend/title', function( $title ) {
    		$opt_titles = get_option('rank-math-options-titles');
    		$title = pll_translate_string( $opt_titles['tax_post_tag_title'], get_locale() );
    		return $title;
    	});
    }
    }
    

    Please let us know how it goes.

    Hi Nigel! So you recognize it’s a Rank Math’s bug, right?

    By the way, I’m not so technical like you, so please, what file I need to change exactly? Is it the archive.php inside of my Theme Folder > template-parts?

    Is there a specific part I need to paste the code?

    And if I change this file and my theme is updated, it could be a problem, right?

    So I must insist, it would be something you guys from Rank Math should fix, even it’s not a priority?

    Thank you!

    Hello,

    It’s perfectly normal that some plugins are incompatible as it’s almost impossible to support all of them.

    So, much like Polylang, we had to make decisions on what plugins to support natively from our plugin.

    You can see the full list of compatible plugins here: https://rankmath.com/compatibility/

    Regarding the code snippet, if you want to try it on your website that can be added to your theme’s functions.php file.

    Don’t hesitate to get in touch if you have any other questions.

    Hi Miguel, thanks for your response, and I really understand your point.

    Of course I don’t think you need to support all plugins, but considering Polylang is one of the most popular and one of the only ones that offer CMS translation, that’s a good reason.

    I also understand that Polylang seems to be reluctant to adapt to Rank Math, so it’s a vicious circle, unfortunately…

    Anyway, do you 100% support WPML (https://wpml.org) too?

    Thanks!

    And Nigel, thank again about this code. I really understand you don’t have any obligation to help or anyone here, so I really appreciate your help.

    I’ve tried your code in my functions.php file but I’ve seen too bugs:

    1. It has translated and replaced all the titles of all pages in all languages (not just Tag pages);

    2. It hasn’t considered Rank Math’s vars like &page% or %term%

    Thanks again!
    Best

    Hello,

    Yes, we do include support for WPML and other ones such as TranslatePress, which has been getting popular lately with our users.

    Regarding the code, could you please try this updated code that should only run on tag pages and should parse the variables:

    
    foreach (pll_languages_list( ['fields' =>'locale'] ) as $current_locale){
    	if (get_locale() == $current_locale && is_tag()) {
    		add_filter( 'rank_math/frontend/title', function( $title ) {
    			$opt_titles = get_option('rank-math-options-titles');
    			$title = pll_translate_string( \RankMath\Helper::replace_vars($opt_titles['tax_post_tag_title']), get_locale() );
    			return $title;
    		});
    	}
    }
    

    Don’t hesitate to get in touch if you have any other questions.

    Thank you very much for your kindness, Miguel!

    About TranslatePress, I don’t like it’s front end translation, because it’s not interesting for a writer, for example. Quite technical in my opinion.

    About your code, I have tried it and the vars are working now. However, the if (get_locale() == $current_locale && is_tag()) { not, only if I remove the && is_tag().

    I have tried to change && to and as well, but it’s not working to recognize just the Tag’s page.

    Also, I’ve tried to replicate the same for the Descriptions, and it isn’t working…

    add_filter( ‘rank_math/frontend/description’, function( $description ) {
    $opt_descriptions = get_option(‘rank-math-options-descriptions’);
    $description = pll_translate_string( \RankMath\Helper::replace_vars($opt_descriptions[‘tax_post_tag_description’]), get_locale() );
    return $description;
    });

    Best and thank you again!

    Nigel
    Rank Math business

    Hello,

    I am not sure why the && tag() condition is not working on your setup as it is working on mine. However, I rewrote the code snippet to reduce the chance of any conflicts:

    
    add_filter( 'rank_math/frontend/title', function( $title ) {
    	foreach (pll_languages_list( ['fields' =>'locale'] ) as $current_locale){
    		if (get_locale() == $current_locale ) {
    			$opt_titles = get_option('rank-math-options-titles');
    			$title = \RankMath\Helper::replace_vars(pll_translate_string( $opt_titles['tax_post_tag_title'], get_locale() ));
    			return $title;
    		}
    	}	
    });
    

    I also made some corrections to the filter for descriptions and it’s working on my setup:

    
    
    add_filter( 'rank_math/frontend/description', function( $description ) {
    	foreach (pll_languages_list( ['fields' =>'locale'] ) as $current_locale){
    		if (get_locale() == $current_locale ) {
    			$opt_titles = get_option('rank-math-options-titles'); //tax_post_tag_description is an item inside the rank-math-options-titles database field.
    			$description = \RankMath\Helper::replace_vars(pll_translate_string( $opt_titles['tax_post_tag_description'], get_locale() ));
    			return $description;
    		}
    	}
    });
    

    Hope that helps. Please let us know if you have questions.

    Nigel, thank you very much! Now it worked even using the && is_tag(), but there is two stranger behaviors:

    1. The separator character I use » OR » was changed for –

    2. The titles of all pages have changed to the page’s title, ignoring the SEO Title set on Rank Math. I mean, in a Post, the page title has changed to the H1 title, ignoring the SEO Title.

    Best

Viewing 15 replies - 1 through 15 (of 27 total)

You must be logged in to reply to this ticket.