| @@ -98,8 +98,21 @@ | ||
| 98 | 98 | if (!$post) { |
| 99 | 99 | return $permalink; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | + // Only append ai_lang if this post actually belongs to a translation group | |
| 103 | + // and has at least one other translation. Otherwise, keep the URL clean. | |
| 104 | + $group = get_post_meta($post->ID, '_ai_translation_group', true); | |
| 105 | + if (!$group) { | |
| 106 | + return $permalink; | |
| 107 | + } | |
| 108 | + | |
| 109 | + $translations = $this->get_group_posts($group, get_post_type($post)); | |
| 110 | + if (empty($translations) || count($translations) <= 1) { | |
| 111 | + // No real translations available for this post | |
| 112 | + return $permalink; | |
| 113 | + } | |
| 114 | + | |
| 102 | 115 | $default_lang = $this->settings['default_lang']; |
| 103 | 116 | $lang = get_post_meta($post->ID, '_ai_lang', true) ?: $default_lang; |
| 104 | 117 | |
| 105 | 118 | // Avoid duplicating the parameter if it's already there. |