You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WPML获取原文译文永久链接异常:德国IP重定向插件问题

Alright, let's tackle this WPML permalink problem you're dealing with. It’s super annoying when you expect www.mysite.com/de/kontakt/ but end up with www.mysite.com/de/contact/ instead—let’s break down the most likely fixes:

1. Verify Page Translation & Slug Setup First

First things first, double-check the basics:

  • Make sure your contact page has a published German translation where the slug is explicitly set to kontakt. Sometimes drafts or incomplete translations won’t sync the slug properly.
  • Head to WPML → String Translation and search for the page slug ("contact"). Ensure the German translation is set to "kontakt" and marked as complete. WPML might not auto-translate slugs unless you’ve configured that, so this step is crucial.

It’s easy to miss a parameter that causes this issue. Make sure you’re passing both the original page ID and the target language code explicitly:

// Get the original English contact page ID
$original_contact_id = get_page_by_path('contact')->ID;
// Generate the German permalink
$german_contact_link = wpml_permalink($original_contact_id, 'de');

Avoid relying on the current language context—specifying 'de' directly ensures WPML knows exactly which language version to fetch.

WPML and WordPress both cache rewrite rules and language data, which can cause stale slugs to stick around:

  • Go to WPML → Support → Troubleshooting and click "Clear WPML cache" to wipe any cached language-related data.
  • Then head to Settings → Permalinks, scroll to the bottom, and click "Save Changes" (no need to edit anything—this just refreshes WordPress’s rewrite rules to pick up the new slug).

4. Rule Out Plugin/Theme Conflicts

Sometimes other plugins or your theme can interfere with WPML’s permalink generation:

  • Temporarily disable all non-WPML plugins, then test your wpml_permalink() call again. If it works, re-enable plugins one by one to find the culprit.
  • Switch to a default WordPress theme (like Twenty Twenty-Four) to see if the issue goes away. If it does, your theme might have a function overriding WPML’s permalink logic.

5. Fallback: Use wpml_object_id to Get the German Page Directly

If wpml_permalink() still isn’t cooperating, try a more direct approach by fetching the German page ID first, then generating the permalink:

$original_contact_id = get_page_by_path('contact')->ID;
// Get the German version of the page ID
$german_contact_id = apply_filters('wpml_object_id', $original_contact_id, 'page', true, 'de');
// Generate the permalink using the German page ID
$german_contact_link = get_permalink($german_contact_id);

This method skips the wpml_permalink() function entirely and uses WPML’s core filter to grab the correct translated page, which often resolves slug mismatch issues.

6. Check WPML Language Redirect Settings

Just to be safe, make sure WPML’s built-in redirects aren’t conflicting with your custom plugin:

  • Go to WPML → Languages → Language Switcher Options and check if "Redirect visitors to their browser's language" is enabled. While your plugin should take priority, disabling this temporarily can help rule out interference.

内容的提问来源于stack exchange,提问作者madhushankarox

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:22:45