• Hello there ??

    I have a weird issue on a WordPress website (Multisite). Occasionally, pages that should be using a custom template or a WP template (like archive.php) starts using index.php instead. When this happens, “if (have_posts())” additionally returns false, even though the page (and its contents) does exist. I have to go into the permalinks settings and simply save them (without even changing them). The problem comes back randomly but quickly enough (a few hours)…

    Originally, the multisite used WPML for multi-language. The problem started just after the switch from WPML to Polylang (with the “WPML to Polylang” plugin).

    Here is the structure of my multisite:

    Main site (4 languages):
    FR: https://example.com/
    NL: /nl/
    EN: /en/
    DE: /de/

    Site 2 (4 languages):
    FR: https://site2.example.com/
    NL: /nl/
    EN: /en/
    DE: /de/

    Site 3 (1 language):
    FR: https://site3.example.com/

    The problem occurs almost exclusively on site 3 (but sometimes on other sites). I have installed the “Query Monitor” plugin. When the problem appears on the news listing for example (/actualites), I notice by analyzing the queries that WP is looking for the language “news” instead of the page “news”: https://snipboard.io/UBPbwj.jpg

    What could cause this? Is it maybe old WPML settings? How can I be sure everything is well configured?

    Thanks in advance,
    Sunduck

Viewing 1 replies (of 1 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    In my opinion, there’s nothing related to the old WPML installation. Just a rewrite rules conflict.

    First, I never saw a rule like ([^/]+)/?$. It looks rather dangerous as it can match a lot of type of content. Generally it is preceded by something else. For example: tag/([^/]+)/?$. If you know what creates this rule then you may have found the source of the conflict.

    Second Polylang may create a query ?lang=xx, where xx is a language code. It does this for the homepages. In this case, the rule looks for example lik this : (en|de)/?$ if you have English and German.

    So I suggest that you switch to Twenty Twenty One, deactivate all plugins except Polylang, deactivate all your custom code and register your post type actualites in the simplest way (with no fancy rewrite rule). In this situation everything should work as expected.

    Then you activate the theme, your plugins one by one (you can visit Settings > Permalinks between each activation to flush the rewrite rules) until you reproduce the issue to find your conflict source. If you have custom code manipulating the rewrite rules, you may start by inspecting this.

Viewing 1 replies (of 1 total)
  • The topic ‘Query trying to set lang instead of page’ is closed to new replies.