🌐 The Problem: Stuck in the Wrong Language
The client’s site used Weglot to manage English and German versions. When users selected German, they were redirected correctly. But when switching back to English, they kept getting bounced back to the German version—even after clearing cookies. The issue was frustrating and made the language switcher feel broken.
🔍 What We Found
- Weglot Auto-Redirect Setting: The plugin was set to redirect based on browser language. This alone can cause looping if not managed carefully.
- Custom Cookie Script: A region-based redirect snippet was setting cookies and overriding manual user choices.
- Admin Login Loop: The redirect script also affected backend access to the German WordPress dashboard, creating a login loop.
🛠️ How We Fixed It
Step 1: Turn Off Auto-Redirects
We disabled Weglot’s browser-based auto-redirection feature to prevent the plugin from making assumptions about user preference.
Step 2: Disable Custom Snippet
We located a custom snippet that set a cookie and forced redirects based on referrer data. This was the main culprit and was temporarily disabled.
Step 3: Inspect the JavaScript
A deeper code audit revealed JavaScript aggressively applying cookie logic and redirection. This was interfering with Weglot’s own controls.
Step 4: Comment the Problem Lines
Instead of deleting, we commented out the section that set and read cookies for redirection. This preserved the snippet in case it was needed later.
Step 5: Clear All Caches
Browser, server, and plugin caches were purged to remove any residual behavior.
Step 6: Retest Everything
We verified proper language switching across devices, in incognito mode, and logged in/out states. Everything worked smoothly.
🎯 Final Result
Users can now switch languages freely without being redirected back to the wrong version. The admin area works normally, and the client confirmed the redirection loop is gone for good.
🔑 Key Learnings
- Custom scripts + plugins = potential conflict
- Auto-redirection and cookies should never clash
- Always test after code changes, even if things look fixed
- Caching can make debugging harder—clear everything!
Need multilingual site support?
Need help improving your WordPress forms or custom workflows? We build clean, reliable, and growth-driven WordPress solutions—without breaking a sweat.
Let’s Talk