WordPress.org

Forums

Polylang
Polylang and Yoast SEO Plugin (39 posts)

  1. miguelcortereal
    Member
    Posted 1 year ago #

    The more I see of Polylang plugin the more I like it.

    Great option to integrate Yoast Plugin with Polylang, don't forget to also add translation for meta descriptions of page templates such as "Page not found" etc.

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    This does not work in current 1.0.3 but should work correctly in the current development version (1.0.3.4).
    http://downloads.wordpress.org/plugin/polylang.zip

  3. miguelcortereal
    Member
    Posted 1 year ago #

    Doesn't work 100% correctly yet.

    As I write this I'm having issues with pages templates.

    For example search template does the query in the apropriate language but meta titles never get translated, it keeps using what is defined at yoast plugin for Search page title page.

    The same for taxonomies and page not found.

  4. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Yes I confirm. I thought that beeing compatible with wpml-config.xml would be sufficient but it is not. My tests were not complete enough. Digging into WordPress SEO code source, I discovered that the options are loaded only one time, and this is done before the language is set by Polylang. This explains why it does not work.

    Setting the language sooner is possible (only) when adding the language code to all urls. I worked on this and got what I think is a working prototype, but I am not ready to mix this with the current development branch of 1.0.x. So I will include it only in 1.1.

    If you are adventurous and want to test it now, please let me know. I can paste the code on pastebin. Do you know how to apply a diff?

  5. miguelcortereal
    Member
    Posted 1 year ago #

    I've never applied a diff, maybe I can do it now.

    I won't be that much adventurous the site is under construction, so I'll be fine.

    Put the code on Pastebin.

  6. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Forget the diff. I put the whole core.php in http://pastebin.com/qfcUdbxa

    You can replace the current core.php from 1.0.3.4 by this one. The changes will not be applied to 1.0.x but in 1.1

  7. miguelcortereal
    Member
    Posted 1 year ago #

    Still not returning meta titles at proper language.

    I've replaced core.php code by the one pasted at pastebin, is there anything else to change ?

  8. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Did you choose to add the language code to all urls in Polylang settings? It won't work if you choose to set the language from the content.

  9. miguelcortereal
    Member
    Posted 1 year ago #

    I did choose to add the language code to all urls in Polylang settings and no way.

  10. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    So I will go on working on this for v1.1

  11. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    I just uploaded the first development version of Polylang 1.1. I would be glad if you could test it and tell me if it improves the situation.

  12. miguelcortereal
    Member
    Posted 1 year ago #

    I've been testing it.

    Yoast breadcrumbs are working fine, but meta titles are still handled by Yoast plugin.

    The same happens with another plugin I have, some of the strings (not all) never get translation. Those strings are single entries of wp-options table, are included at my wpml-config.xml file and show up at polylang settings.

    If you think useful to give you the credentials of the site, I will, so that you can better reproduce these issues, just let me know how can I send them for you.

  13. miguelcortereal
    Member
    Posted 1 year ago #

    Update!!

    I've just got it working.

    If I include all Yoast wp_option table keys at wpml-config.xml file it starts working, by being included at polylang strings theme's group.

    wordpress-seo strings group has the same keys like it had before which brings a duplication.

    This confirms that those keys included at wordpress-seo group never get to action, but they do if in the theme.

    However, the strings from the other plugin that don't want to work are also assigned to the theme group.

  14. miguelcortereal
    Member
    Posted 1 year ago #

    Not sure if it's important but my wpml-config.xml file is in child theme folder.

  15. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry. There is something I don't understand. Do you mean that it does not works if you keep the wpml-config.xml of WordPress SEO as is, but it works if you copy the same file in your theme directory ?

  16. miguelcortereal
    Member
    Posted 1 year ago #

    By default without adding any wpml-config.xml file, wordpress seo strings show up at admin polylang settings to enter each language translation. It turns that it doesn't work.

    But if you add them at wpml-config.xml it works.

    As a result these Yoast wp-option fields show up at polylang settings twice. The originals, the ones from the plugin integration with Yoast are in wordpress seo group, the ones added at wpml-config.xml file show up at theme's group. These mentioned groups show up at first column of the table of the admin polylang settings.

    All I had to do was leave alone the wordpress seo group and set my meta titles translation at theme group.

    Here's my wpml-config.xml file saved at child theme folder:

    <wpml-config>
    	<admin-texts>
    		<key name="wp_cart_title" />
    		<key name="wp_cart_empty_text" />
    		<key name="addToCartButtonName" />
    		<key name="cart_return_from_paypal_url" />
    		<key name="cart_products_page_url" />
    		<key name="cart_checkout_page_url" />
    		<key name="pitch_theme_settings">
    			<key name="front_page_portfolio_home" />
    			<key name="front_page_cta_text" />
    			<key name="front_page_cta_button_text" />
    			<key name="front_page_cta_button_url" />
    			<key name="front_page_home_blog" />
    			<key name="front_page_home_title_latest_projects" />
    			<key name="front_page_home_title_blog" />
    			<key name="front_page_home_title_clients" />
    			<key name="project_tags" />
    			<key name="project_archive_title" />
    			<key name="project_view_text" />
    			<key name="project_url_slug" />
    			<key name="type_project" />
    			<key name="type_feature" />
    			<key name="type_client" />
    			<key name="type_slide" />
    			<key name="text_footer_text" />
    			<key name="text_search_placeholder" />
    			<key name="text_comments_closed" />
    			<key name="text_not_found" />
    			<key name="general_demo_mode" />
    			<key name="general_search_input" />
    			<key name="general_menu_extras" />
    			<key name="general_topbar_menu" />
    			<key name="general_scale_main_menu" />
    		</key>
    		<key name="wpseo_titles">
    			<key name="title-skill" />
    			<key name="title-category" />
    			<key name="title-post_tag" />
    			<key name="title-author" />
    			<key name="title-archive" />
    			<key name="title-search" />
    			<key name="title-404" />
    			<key name="title-ptarchive-project" />
    		</key>
    	</admin-texts>
    </wpml-config>
  17. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    That's really strange. All wpml-config.xml files are loaded in the same function. So I don't understand why it works when the options are loaded from your theme child and not from you wordpress-seo directory...

    And it works on my test site...

    Could you try to modify the line 222 of polylang/include/wpml-compat.php from

    add_action('plugins_loaded', array(&$this, 'init'));

    to

    add_action('plugins_loaded', array(&$this, 'init'), 1);

    Could you also try with only WordPress SEO + Polylang + a default theme such as Twenty Twelve. I would like to check if there could be interferences between two wpml-config.xml files

  18. miguelcortereal
    Member
    Posted 1 year ago #

    I've deleted these lines from my wpml-config.xml file saved at child theme directory:

    <key name="wpseo_titles">
    			<key name="title-skill" />
    			<key name="title-category" />
    			<key name="title-post_tag" />
    			<key name="title-author" />
    			<key name="title-archive" />
    			<key name="title-search" />
    			<key name="title-404" />
    			<key name="title-ptarchive-project" />
    		</key>

    and replaced line 222 of polylang/include/wpml-compat.php

    Doesn't work.

    Keeping the change at line 222 and adding those lines again at wpml-config.xml it get back to work.

    I'm not or ever been using more than one wpml-config.xml file, my first option, that I kept, was to place this file at child theme directory and not at polylang directory or theme directory to prevent the lost of the file on next polylang or theme update.

  19. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    I still did not reproduce the issue...

    WordPress SEO does use a wpml-config.xml file to ask for strings translations, just as you do with your child theme. So at least two files are read.

    And since, at the moment, I have no other explanation than some conflict between the two files, that's why I asked you to test with a default theme without any wpml-config.xml file (so that only the one from WPSEO get read).

    Just in case, are you using the latest version of WPSEO?

  20. miguelcortereal
    Member
    Posted 1 year ago #

    I'm using the latest version of WPSEO.

    I've performed the test as follow:

    I did remove wpml-config.xml from my child theme, switched to twenty twelve theme and all meta titles were working correctly. Then activated again my child Pitch Theme without wpml-config.xml and all meta titles from templates were working execept custom taxonomies that kept displaying at base language, Portuguese in my case.

    During the test with twenty twelve couldn't see custom taxonomies meta titles working since they are part of Pitch Theme.

    I've moved again wpml-config.xml file to the child theme directory, but not before of delete all the keys from wpseo section with exception for the custom taxonomies, since the rest were currently working fine.

    Keys deleted:

    <key name="title-category" />
    <key name="title-post_tag" />
    <key name="title-author" />
    <key name="title-archive" />
    <key name="title-search" />
    <key name="title-404" />

    As I was testing it, all templates (404 not found, search, categories, tags and all custom taxonomies) started to show meta titles in Portuguese.

    It seems that your theory about the conflict between the two files is correct.

    For now the workaround is to repeat all wpseo keys at wpml-config.xml file at least for cases like mine where there are custom txonomies not handled for translation and let it override the default settings provided at Polylang admin settings.

  21. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you very much for your test. I will investigate in that direction.

  22. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    I created the simplest child theme of your theme pitch, took your wpml-config.xml, removed the WP SEO options. And unfortunately do not reproduced the same problem as you. I really don't understand what can happen with your installation.

  23. miguelcortereal
    Member
    Posted 1 year ago #

    Hi Chouby,

    Four months passed since this discussion. I'm starting a new site this time using suffusion theme. This site will also be multilingue and I'm facing again this same issue with wp-seo.

    When you made the test, did you change wp-config.php at language definition to define('lang', 'pt_PT') ?

    Suddenly occurred to me that in a multilingue site this definition doesn't make sense and might conflict with your plugin's base language function.

  24. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    This should not conflict.

  25. ReactorShop
    Member
    Posted 1 year ago #

    Hi Chouby.

    I really appreciate the work you've done with this plugin. For now, I've been looking for a solution to a situation partially similar to the one indicated here. This is my information:

    1. My Polylang version is 1.1.4 (current).
    2. I deleted, reinstalled WordPress with all the plugins I'm currently using, then deleted and reinstalled Polylang, and I still have the same issue.
    3. My permalink settings are http://www.mywebsite.com/blog/%category%/%postname%/
    4. I'm not using a static front page
    5. My Polylang settings are:
    a) Language set according to browser preference
    b) The language code is added to all urls
    c) Remove /language/ in pretty permalinks
    d) Activate languages and translations for all types.
    6. My child theme is Twenty Twelve Dark, which is referenced to the Twenty Twelve WordPress standard theme.

    The plugins that create conflicts are both the Yoast SEO and the WP e-Commerce plugins.
    My website is bilingual (English/Spanish), using English as standard.
    In my case, define('lang',' '), as the WordPress standard installation sets.

    Even though the wpml-config.xml file exists at the Yoast SEO folder, I don't see their strings at the Polylang's Strings translation tab.
    So, based on miguelcortereal comments, I created a wpml-config.xml file and then I placed it into my child theme folder, and later into the WP e-commerce folder, just to test further.

    In both cases, the Polylang's Strings translation tab were populated with both the Yoast SEO and the WP e-Commerce strings, and in both cases, the Group column either showed the child theme name or the WP e-Commerce plugin name.

    Here are the contents of my xml file:

    <wpml-config>
        <admin-texts>
            <key name="product_list_url" />
            <key name="shopping_cart_url" />
            <key name="checkout_url" />
            <key name="transact_url" />
            <key name="user_account_url" />
            <key name="wpseo_titles">
                <key name="title-home" />
                <key name="metadesc-home" />
                <key name="metakey-home" />
                <key name="title-post" />
                <key name="metadesc-post" />
                <key name="metakey-post" />
                <key name="title-page" />
                <key name="metadesc-page" />
                <key name="metakey-page" />
                <key name="title-attachment" />
                <key name="metadesc-attachment" />
                <key name="metakey-attachment" />
                <key name="title-category" />
                <key name="metadesc-category" />
                <key name="metakey-category" />
                <key name="title-post_tag" />
                <key name="metadesc-post_tag" />
                <key name="metakey-post_tag" />
                <key name="title-author" />
                <key name="metadesc-author" />
                <key name="metakey-author" />
                <key name="title-archive" />
                <key name="metadesc-archive" />
                <key name="title-search" />
                <key name="title-404" />
            </key>
        </admin-texts>

    In my case, my problem is that the WP e-Commerce theme works centered around the Products Page. The wp_options table shows the product_list_url value as http://www.mysite.com/en/products-page/.

    So, if I put the xml file into either of the 2 locations indicated before, and then I change the Polylang Spanish product_list_url string translation to http://www.mysite.com/es/pagina-de-productos/ as the permalink for the page in Spanish indicates, and then I try to navigate there, no problem happens.

    But, if I click on "more details" at the grid view for the product currently displayed, then I get the 404 error, which is now titled in Spanish Página no encontrada, instead of Page not Found, because I translated the title-404 Yoast SEO entry at the Strings translation tab, with the xml file located at either the child them or the WP e-Commerce folders.

    If I do all these operations selecting the English language, I don't have any 404 problems. It seems to me that this happens because the product_list_url at the wp_options table is already in English and it's not being translated.

    If I erase the new xml file and I try to click the "more details" link while on grid view for the product being displayed, my website navigates towards http://www.mysite.com/es/products-page/<category in Spanish>/<post title in Spanish>/, without giving me the 404 error.

    The odd thing is that the Products Page part of the permalink never translates. It stays in English.

    I checked the wpsc-functions.php for the WP e-Commerce plugin and found these functions related to the Products Page

    function wpsc_get_page_post_names() {
    	$wpsc_page['products']            = basename( get_option( 'product_list_url' ) );
    	$wpsc_page['checkout']            = basename( get_option( 'checkout_url' ) );
    	$wpsc_page['transaction_results'] = basename( get_option( 'transact_url' ) );
    	$wpsc_page['userlog']             = basename( get_option( 'user_account_url' ) );
    
    	return $wpsc_page;
    }
    
    function wpsc_add_https_to_page_url_options( $url ) {
    	return str_replace( 'http://', 'https://', $url );
    }
    if ( is_ssl() ) {
    	add_filter( 'option_product_list_url',  'wpsc_add_https_to_page_url_options' );
    	add_filter( 'option_shopping_cart_url', 'wpsc_add_https_to_page_url_options' );
    	add_filter( 'option_transact_url',      'wpsc_add_https_to_page_url_options' );
    	add_filter( 'option_user_account_url',  'wpsc_add_https_to_page_url_options' );
    }
    
    function wpsc_update_permalink_slugs() {
    	global $wpdb;
    
    	$wpsc_pageurl_option = array(
    		'product_list_url'  => '[productspage]',
    		'shopping_cart_url' => '[shoppingcart]',
    		'checkout_url'      => '[shoppingcart]',
    		'transact_url'      => '[transactionresults]',
    		'user_account_url'  => '[userlog]'
    	);
    
    	$ids = array();
    
    	foreach ( $wpsc_pageurl_option as $option_key => $page_string ) {
    		$id = $wpdb->get_var( "SELECT <code>ID</code> FROM <code>{$wpdb->posts}</code> WHERE <code>post_type</code> = 'page' AND <code>post_content</code> LIKE '%$page_string%' LIMIT 1" );
    
    		if ( ! $id )
    			continue;
    
    		$ids[$page_string] = $id;
    
    		$the_new_link = get_page_link( $id );
    
    		if ( stristr( get_option( $option_key ), "https://" ) )
    			$the_new_link = str_replace( 'http://', "https://", $the_new_link );
    
    		if ( $option_key == 'shopping_cart_url' )
    			update_option( 'checkout_url', $the_new_link );
    
    		update_option( $option_key, $the_new_link );
    	}
    
    	update_option( 'wpsc_shortcode_page_ids', $ids );
    }

    these other 2 files of the WP e-Commerce plugin include the product_list_url too. The shopping cart, transaction results and user account pages create the same problem, but I'm not using them for now.

    wpsc-cart_widget.php
    wpsc-shopping_cart_page.php

    What I'm looking for is to present the Product Page permalink part in Spanish when Spanish is selected or in English if English is selected and avoid the 404 error. On the other hand, it seems odd to me that the wpml-config.xml file located at the Yoast SEO folder is not included at the Strings translation tab until I copy it into my child theme folder or the WP e-Commerce folder, and even then, the WP e-Commerce plugin tries to load the English permalink for the Products page, as it is in the wp_options table and generates 404 errors if it tries to load the translated permalink.

    What do you recommend me to do?

    My website is http://www.reactorshop.com, if you have a chance to navigate and see the Products Page permalink part always in English, when you select Spanish and right after you click at the Pagina de Productos Menu. Just hover your mouse over the "Mas Detalles" link and you'll see.

    I only listed one product, in case I have to redo the website installation and configuration again.

    If you require any additional information, please don't hesitate to ask. Thank you in advance.

  26. miguelcortereal
    Member
    Posted 1 year ago #

    You're right Chouby, that define( 'wplang', '' ) doesn't conflict.

    However, I reasure you that for me yoast wpseo strings only get to working by replicating them at a wpml-config.xml file.

    I've tested it with and without the file and it works with but doesn't without.

    This time the issue was at Archives meta titles, the other strings looked to be fine.

    There was a strange behaviour too that caught my attention, when I placed the wpml-config.xml file at my theme's child theme folder, it didn't start to work imediatly, so after playing a bit with polylang definitions such as browser language detection, URL modifications options and permalink update because of the URL with or without /language/ and eventually re-save some of the posts tags and categories, my meta titles got working for each language.

  27. ReactorShop
    Member
    Posted 1 year ago #

    I had to switch the setting "The language code is added to all urls" to "The language is set from content" because I started getting 404 errors all over the place and could only get to the Home page without getting 404s.

    Switching this option removes the language code, but "solves" my 404 problem. I guess that since I didn't flush the cache (I'm using WP Super Cache), I worked for a while with a previous setting I had (language set from content).

    Regarding wpml-config.xml, miguelcortereal is right. The wpml-config.xml file is not being included at the Strings translation tab, until you copy it to another plugin folder.

  28. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Yes I am aware that this is a "not solved" issue. Polylang is looking for all wpml-config.xml files in the directory of all active plugins. I don't understand what could be specific to wordpress-seo plugin.

    When I make test at home, everything works as expected. I just remade a test with latests versions of WP, WPSEO and Polylang.

    Please note however that strings intentionnally don't appear in strings translations table if they are left empty in plugins settings.

  29. miguelcortereal
    Member
    Posted 1 year ago #

    This is just a thought, but I've noticed that on last Yoast Seo Plugin update, there was a fix related with strings reported at changelog.

    Who knows if the problem is at Seo Plugin ?

  30. ReactorShop
    Member
    Posted 1 year ago #

    My WordPress website broke with 404s all over the place, so I reinstalled WordPress, again, yesterday morning. I decided to install only the plugins that I deemed absolutely necessary and let the more complex ones (e.g. WP Super Cache) at their default settings, without customization.

    My website it's been working fine for a while now (it was taking less than 4 hours to brake as I customized it before), so my guess is that certain custom settings from WP Super Cache (maybe the use of mod_rewrite instead of PHP to serve cached files) or Better WP Security (I didn't install it this time) might be causing the Polylang plugin or the whole WordPress installation to brake.

    It's working fine using the language code (/en/ or /es/) added to all urls when using pretty permalinks, as it is your recommended setting when using Yoast SEO. The permalink part for the WP e-Commerce pages titles switch to English, when containing a post, but that's something that I can live with.

    I've set up a localhost mirror copy of my website in my mac, using it's native Apache and PHP installations, and I've been going through it with Netbeans, but it takes a lot of time to debug a system so big and complex, and sometimes time is limited.

    That's why, Chouby, I totally understand and respect the work you've been doing with the Polylang plugin. We just hope that you get the time to fix these situations at a later release.

    Thank you, Chouby!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic