Compatibility issue with Polylang
-
Hi!
I really like this plugin, it saved me countless hours. Thank you for that!
I have an issue regarding its compatibility with Polylang Pro.
It works has it should so long as I do not try to translate the post types slugs.
I tried to translate the slugs with use of a standard .po file or using polylang built-in string translation module.
It breaks BTF rewrite rules.
I searched quite a bit before posting, but could not find any information on the matter. Is it something that was mentioned before? Did I miss something somewhere.Any help is welcome!
Thank you
-
Hi,
Thank you! If you enjoy the plugin please leave a review so others can find it too ??
I don’t think I’ve considered the possibility of translated post type slugs when using Polylang. Is it this you’ve done: https://polylang.pro/doc/translating-urls-slugs/ ?
I’m not sure how BTF would pick up on the translated value tho.. does not seem to be anything in polylangs documentation. Can you perhaps investigate how the translated slug is implemented?
Hi Jonathan !
Thanks for your enlighting answer.
Yes this is the method I used.
I’ll ask Frédéric Demarle, author of Polylang if he can give specifics about how the slug translation is implemented.Ideally BTF would pickup on translations for post type slugs and taxonomy slugs and terms. Ideally of course ??
I’ll get back to the thread with the information I’m able to gather.
Thanks
While Frédéric can be given the time to give an answer, I’ve looked rapidly and it looks like Polylang simply edit WordPress rewrite rules.
At least, I’ve been able to determine that a change of slug in Polylang settings is reflected in the wp_options table on the field “rewrite_rules” which lists all the rewrite rules.
Does this helps?Hmmm okay..
Well it helps a bit. But just to be clear, are you getting different post type slugs depending on language when you do this? Or is it changed for all languages?Because just changing the existing rewrite rules would mean a change to all languages (I think).. on the other hand, if he just adds the rewrite rules for the translated slugs I wonder how he then make sure WP uses those language specific slugs.
No, the slug is different according to the language.
ex:
– https://www.domain.com/acheter/item-12
– https://www.domain.com/en/buy/item-12The rewrite rule takes the current language into account.
In my example, french being the default language.Here are the rules I have extracted from the wp_option table that concerns may “sale” cpt:
s:46:"(en)/(acheter|buy)/[^/]+/attachment/([^/]+)/?$" s:49:"index.php?lang=$matches[1]&attachment=$matches[3]" s:41:"(acheter|buy)/[^/]+/attachment/([^/]+)/?$" s:32:"index.php?attachment=$matches[2]" s:56:"(en)/(acheter|buy)/[^/]+/attachment/([^/]+)/trackback/?$" s:54:"index.php?lang=$matches[1]&attachment=$matches[3]&tb=1" s:51:"(acheter|buy)/[^/]+/attachment/([^/]+)/trackback/?$" s:37:"index.php?attachment=$matches[2]&tb=1" s:76:"(en)/(acheter|buy)/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$" s:66:"index.php?lang=$matches[1]&attachment=$matches[3]&feed=$matches[4]" s:71:"(acheter|buy)/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$" s:49:"index.php?attachment=$matches[2]&feed=$matches[3]" s:71:"(en)/(acheter|buy)/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$" s:66:"index.php?lang=$matches[1]&attachment=$matches[3]&feed=$matches[4]" s:66:"(acheter|buy)/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$" s:49:"index.php?attachment=$matches[2]&feed=$matches[3]" s:71:"(en)/(acheter|buy)/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$" s:67:"index.php?lang=$matches[1]&attachment=$matches[3]&cpage=$matches[4]" s:66:"(acheter|buy)/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$" s:50:"index.php?attachment=$matches[2]&cpage=$matches[3]" s:52:"(en)/(acheter|buy)/[^/]+/attachment/([^/]+)/embed/?$" s:60:"index.php?lang=$matches[1]&attachment=$matches[3]&embed=true" s:47:"(acheter|buy)/[^/]+/attachment/([^/]+)/embed/?$" s:43:"index.php?attachment=$matches[2]&embed=true" s:35:"(en)/(acheter|buy)/([^/]+)/embed/?$" s:54:"index.php?lang=$matches[1]&sale=$matches[3]&embed=true" s:30:"(acheter|buy)/([^/]+)/embed/?$" s:37:"index.php?sale=$matches[2]&embed=true" s:39:"(en)/(acheter|buy)/([^/]+)/trackback/?$" s:48:"index.php?lang=$matches[1]&sale=$matches[3]&tb=1" s:34:"(acheter|buy)/([^/]+)/trackback/?$" s:31:"index.php?sale=$matches[2]&tb=1" s:59:"(en)/(acheter|buy)/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$" s:60:"index.php?lang=$matches[1]&sale=$matches[3]&feed=$matches[4]" s:54:"(acheter|buy)/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$" s:43:"index.php?sale=$matches[2]&feed=$matches[3]" s:54:"(en)/(acheter|buy)/([^/]+)/(feed|rdf|rss|rss2|atom)/?$" s:60:"index.php?lang=$matches[1]&sale=$matches[3]&feed=$matches[4]" s:49:"(acheter|buy)/([^/]+)/(feed|rdf|rss|rss2|atom)/?$" s:43:"index.php?sale=$matches[2]&feed=$matches[3]" s:47:"(en)/(acheter|buy)/([^/]+)/page/?([0-9]{1,})/?$" s:61:"index.php?lang=$matches[1]&sale=$matches[3]&paged=$matches[4]" s:42:"(acheter|buy)/([^/]+)/page/?([0-9]{1,})/?$" s:44:"index.php?sale=$matches[2]&paged=$matches[3]" s:54:"(en)/(acheter|buy)/([^/]+)/comment-page-([0-9]{1,})/?$" s:61:"index.php?lang=$matches[1]&sale=$matches[3]&cpage=$matches[4]" s:49:"(acheter|buy)/([^/]+)/comment-page-([0-9]{1,})/?$" s:44:"index.php?sale=$matches[2]&cpage=$matches[3]" s:43:"(en)/(acheter|buy)/([^/]+)(?:/([0-9]+))?/?$" s:60:"index.php?lang=$matches[1]&sale=$matches[3]&page=$matches[4]" s:38:"(acheter|buy)/([^/]+)(?:/([0-9]+))?/?$" s:43:"index.php?sale=$matches[2]&page=$matches[3]" s:35:"(en)/(acheter|buy)/[^/]+/([^/]+)/?$" s:49:"index.php?lang=$matches[1]&attachment=$matches[3]" s:30:"(acheter|buy)/[^/]+/([^/]+)/?$" s:32:"index.php?attachment=$matches[2]" s:45:"(en)/(acheter|buy)/[^/]+/([^/]+)/trackback/?$" s:54:"index.php?lang=$matches[1]&attachment=$matches[3]&tb=1" s:40:"(acheter|buy)/[^/]+/([^/]+)/trackback/?$" s:37:"index.php?attachment=$matches[2]&tb=1" s:65:"(en)/(acheter|buy)/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$" s:66:"index.php?lang=$matches[1]&attachment=$matches[3]&feed=$matches[4]" s:60:"(acheter|buy)/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$" s:49:"index.php?attachment=$matches[2]&feed=$matches[3]" s:60:"(en)/(acheter|buy)/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$" s:66:"index.php?lang=$matches[1]&attachment=$matches[3]&feed=$matches[4]" s:55:"(acheter|buy)/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$" s:49:"index.php?attachment=$matches[2]&feed=$matches[3]" s:60:"(en)/(acheter|buy)/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$" s:67:"index.php?lang=$matches[1]&attachment=$matches[3]&cpage=$matches[4]" s:55:"(acheter|buy)/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$" s:50:"index.php?attachment=$matches[2]&cpage=$matches[3]" s:41:"(en)/(acheter|buy)/[^/]+/([^/]+)/embed/?$" s:60:"index.php?lang=$matches[1]&attachment=$matches[3]&embed=true" s:36:"(acheter|buy)/[^/]+/([^/]+)/embed/?$" s:43:"index.php?attachment=$matches[2]&embed=true"
There is a second field in the wp_option that seems to contain information about the slug translation made by Polylang:
The field is “_transient_pll_translated_slugs” and the relevant informatin to the “sale” cpt is:
s:4:"sale";a:2:{s:4:"slug";s:7:"acheter";s:12:"translations";a:2:{s:2:"fr";s:7:"acheter";s:2:"en";s:3:"buy";}}s:12:"archive_sale";a:3:{s:4:"hide";b:1;s:4:"slug";s:7:"acheter";s:12:"translations";a:2:{s:2:"fr";s:7:"acheter";s:2:"en";s:3:"buy";}}
Hmmm… so how does polylang take over and throw the translated rules instead.. Maybe it highjacks the page and redirects before rendering.
- The topic ‘Compatibility issue with Polylang’ is closed to new replies.