Polylang and Yoast SEO Plugin (39 posts)

  1. v4ssi
    Posted 2 years ago #

    I want share my problem and solution.
    Today i've discovered that my meta description and all other SEO string were not changing with the language of the page.
    They were set correctly, polylang was able to get them with a manually test (ex: pll__(__('test var')).
    So wpml-compat.php line 362 was doing all correctly.

    I'm gone to check if the problem was SEO by Yoast and apparently i was a bit confused because testing class-frontend.php and checking get_wpseo_options() and metadesc() the array was in the default language and for no reason was the right language.. anyway...to make a long story short i've set in polylangs->settings->url modifications->"The language code, for example /en/, is added to all urls when using pretty permalinks." than i've re-saved in settings->permalinks and all was working good.

    While i was finishing this post i've checked for the 1000 times the documentation of polylang and i've found this sentence "For example, it is recommended to use the second option when running Polylang together with WordPress SEO by Yoast."

    In my humble opinion it's better add this thing to the FAQ:
    I've installed SEO by Yoast but the custom strings are not working properly
    Answer with the solution above.

    I hope this will save someone. ^^
    As usual sorry for my English.

    I've added here this post because is similar to this thread and this other old thread

  2. ReactorShop
    Posted 2 years ago #

    I discovered today which plugin is causing my website to break with 404s all over the place when combining Polylang, Yoast SEO, WP e-Commerce, WP Super Cache and a small bunch of other (really great) plugins.

    It's the WP e-Commerce Predictive Search plugin. It's not enough to deactivate it or uninstall it. The damage is already done.

    I had to revert to a backup done earlier today and it worked as it was before.

    Just so you all know.

  3. 404
    Posted 2 years ago #

    I'm using Yoast SEO & Polylang, and the strings are not changing when the language changes.
    Apparently, I have to use the language code in pretty permalinks.

    Is there a way to avoid using the language code in pretty permalinks in order to change Yoast SEO strings when the language changes?

  4. Chouby
    Plugin Author

    Posted 2 years ago #

    WPSEO does not work correctly when you set the language by content. I don't know if there is a workaround.

    In current stable version, it should work correctly when adding the language code in urls. I did not test but it should also work when using the subdomains or different domains with v1.2beta

  5. miguelcortereal
    Posted 2 years ago #

    @ Chouby

    I might be pointing something very stupid or clearly ignorant but I've stumbled in an option offered by Buddypress plugin that eventually could be a solution for the wpseo strings that doesn't translate because seo Plugin actuates earlier than Polylang.

    To ease Buddypress customizations and hacks, there's the option to create a bp-custom.php file and place it at /wp-content/plugins/ folder.

    At this location this file is read earlier than anything. I was thinking that moving or creating aditional Polylang code for this location it could solve the priority issue.

  6. Chouby
    Plugin Author

    Posted 2 years ago #

    There is such option in Polylang too (in wp-content/polylang/pll-config.php). That's a good place to add custom code specific to Polylang without adding a new plugin.

    That's right. When set from content, the language is loaded after WPSEO loaded its options. So we need to reload the options after the language has been set to get the correct translation. The feature is now included in Polylang 1.2 (1.2dev50).

  7. 404
    Posted 2 years ago #

    Thank you Chouby, Polylang is the best multilingual plugin for WordPress.

  8. ReactorShop
    Posted 2 years ago #

    I'm not sure if it's the same situation described above, but after further testing PLL 1.2dev54, I found out why the Yoast's SEO wpml-config.xml file was not loading into my Polylang's String Translation tab.

    I have a WordPress multi-site installation, and I install all my plugins from my Network Admin Dashboard and do a site wide network activation.

    If you do this, when you go out of your Network Admin Dashboard into a specific site dashboard and look for plugins, you're going to find none. This happens unless you deactivate them in your Network Admin Dashboard. Then you are going to find them on a per-site basis and will have the option to activate them for a specific site only.

    For me, this represents that if I do a get_option('active_plugins'), I'm going to get no plugin information at all.

    Polylang currently checks for plugins activated on a single site installation or per-site basis only:

    ...polylang/include/wpml-compat.php, line 472
                    // plugins
    		foreach (get_option('active_plugins') as $plugin) {
    			if (file_exists($file = dirname(POLYLANG_DIR).'/'.dirname($plugin).'/wpml-config.xml'))
    				$this->xml_parse(file_get_contents($file), dirname($plugin));

    What I did, is to check for get_site_option('active_sitewide_plugins'), and this will pull all the network activated plugins paths, and this will allow Polylang to read and integrate their wpml-config.xml data into the String Translation tab:

    // network activated plugins
    		foreach (get_site_option( 'active_sitewide_plugins') as $plugin => $time ) {
    			if (file_exists($file = dirname(POLYLANG_DIR).'/'.dirname($plugin).'/wpml-config.xml'))
    				$this->xml_parse(file_get_contents($file), dirname($plugin));

    And now all of Yoast's SEO metadata is shown to me at the Strings Translation tab ready for me to translate.

    It's important to keep both code snippets in that file because of what I described in the bold paragraph.

    Chouby, I hope you can add this to the next Polylangs' dev.

    Thank you, Chouby!

  9. Chouby
    Plugin Author

    Posted 2 years ago #

    Oh YES!

    1.2dev55 now checks for sitewide active plugins too.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic