• Alexsoluweb

    (@alexgmenard)


    Hi Polylang Support Team,

    I am currently experiencing an issue where Polylang does not seem to recognize custom endpoints on my WordPress site. I’ve created custom endpoints (e.g., /intranet-login) that should be accessible in different languages, but Polylang does not automatically recognize or handle these endpoints with the correct language context in some situations.

    What I’ve Tried So Far:

    1. Custom Rewrite Rules:
      I have added language-specific rewrite rules for each language using add_rewrite_rule() to support multilingual endpoints. However, Polylang does not seem to handle these rules correctly. However it seems Polylang already add the lang rewrites so i have removed it to avoid duplications.
    2. Language permalink Handling Logic:
      When using the language switcher, it dont switch accordingly for thos endpoints, but the permalinks itself are working correctly. I wonder why it’s not switching accordingly for the language endpoints.
    3. Flushing Rewrite Rules:
      I’ve flushed the rewrite rules both manually (via Settings > Permalinks) and programmatically, but the issue persists.

    The Issue:

    Despite these efforts, Polylang does not seem to recognize my custom endpoints correctly and does not switch to the appropriate language when using these endpoints.My Questions:

    1. Is there a specific way to register custom endpoints with Polylang so they are recognized and handled correctly?
    2. Are there any hooks or functions provided by Polylang that I should use to ensure my custom endpoints are multilingual-aware?
    3. Could you provide guidance or best practices on how to make custom endpoints fully compatible with Polylang’s multilingual management?

    Any help or guidance you could provide would be greatly appreciated!

    Thank you for your time and assistance.

    Best regards,

Viewing 1 replies (of 1 total)
  • Thread Starter Alexsoluweb

    (@alexgmenard)

    I got the language switcher resolving url’s correctly with it:

    // Add the custom language link to polylang language switcher.
    add_filter('pll_the_language_link', function ($url, $slug, $locale) {
    global $wp_query;
    if (isset($wp_query->query_vars['intranet-login'])) {
    $url = home_url($slug . '/intranet-login');
    return $url;
    }
    return $url;
    }, 10, 3);

    But i still wonder, what is the proper way to make Polylang aware of custom endpoints, if it has one…

    Regards,

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.