• Resolved sergzsv

    (@sergzsv)


    Hi Sami,

    I have issue with “Custom Permalinks” (ver 0.9.2) and “Polylang” (ver 2.1.5) in WordPress 4.8. Here is my “Polylang” settings:

    * I have 2 languages: “uk”, “ru”
    * Default language is “uk”
    * Option “URL modifications” is set to “The language is set from the directory name in pretty permalinks” (so general URL template looks like: “https://example.com/xx/my-post”, where “xx” is language code)
    * Option “Hide URL language information for default language” is enabled (so “uk” URls look like “https://example.com/my-post”)
    * Option “Remove /language/ in pretty permalinks” is enabled

    I see some URLs with non-default language don’t work properly. E.g. I have “https://example.com/ru/abc” article (“abc” is slug). I can make it “https://example.com/ru/new-slug” and response will be “200 OK” but if I set it to “https://example.com/ru/some/complex/path/here” the response is “404 Not found”.

    Could you check it please?

    Thanks,
    Sergey

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sergzsv

    (@sergzsv)

    BTW: I have investigated “Custom Permalinks” source code and it looks like it will not work with my “Polylang” configuration (and my URLs) properly. I think plugin strips added by “Polylang” language incorrectly.

    Here is the patch that has fixed the issue for me:

    
    diff --git a/wp-content/plugins/custom-permalinks/custom-permalinks.php b/wp-content/plugins/custom-permalinks/custom-permalinks.php
    index 0f28913..c091763 100644
    --- a/wp-content/plugins/custom-permalinks/custom-permalinks.php
    +++ b/wp-content/plugins/custom-permalinks/custom-permalinks.php
    @@ -816,12 +816,24 @@ function custom_permalinks_check_conflicts($requested_url = '') {
         $polylang_config = get_option('polylang');
         if ($polylang_config['force_lang'] == 1) {
     
    -      if(strpos($requested_url, 'language/') !== false)
    -        $requested_url = str_replace("language/", "", $requested_url);
    -      
    -      $remove_lang = ltrim(strstr($requested_url, '/'), '/');
    -      if ($remove_lang != '')
    +      if($polylang_config['rewrite'] == 1) {
    +        $requested_url = str_replace('language/', '', $requested_url);
    +      }
    +
    +      $langs = pll_languages_list();
    +
    +      if($polylang_config['hide_default'] == 1) {
    +        $default_lang_idx = array_search($polylagn_config['default_lang'], $langs);
    +        unset($langs[$default_lang_idx]);
    +      }
    +
    +      $langs = implode('|', $langs);
    +
    +      $remove_lang = preg_replace('/^'.$langs.'\//', '', $requested_url);
    +
    +      if ($remove_lang != '') {
             return $remove_lang;
    +      }
         }
       }
    

    Could you double check, please?

    • This reply was modified 7 years, 5 months ago by sergzsv.
    Plugin Author Sami Ahmed Siddiqui

    (@sasiddiqui)

    HI sergzsv ( @sergzsv )

    Are you the Permalinks Customizer or Custom Permalink. These are 2 different plugins.

    Can you please confirm which of the plugin you are using?

    Thanks,
    Sami

    Plugin Author Sami Ahmed Siddiqui

    (@sasiddiqui)

    Hi @sergzsv

    Conflict with PolyLang Plugin has been resolved. Please try the latest version of this plugin.

    Let me know if it doesn’t work for you or you found some issue in it.

    Thanks,
    Sami

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Permalinks + Polylang issue’ is closed to new replies.