Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @sacconi

    To transform links dynamically from Italian to German or English, you can use a custom function in your theme’s functions.php file. This code automatically detects the Italian short links and redirects them to the corresponding German or English URLs:

    add_action('template_redirect', function() {$url = $_SERVER['REQUEST_URI'];if (strpos($url, '/?p=') !== false) {$post_id = url_to_postid($url);$lang_prefix = (strpos($_SERVER['HTTP_HOST'], 'de') !== false) ? 'de' : 'en';$translated_url = get_permalink($post_id);if ($lang_prefix) {$translated_url = str_replace('sacconicase.com', "$lang_prefix.sacconicase.com", $translated_url);wp_redirect($translated_url, 301);exit;}}});

    Alternatively, a plugin like Polylang or WPML can help manage multilingual links, enabling easy URL switching between languages

    Thread Starter sacconi

    (@sacconi)

    I dont need an automatic redirect, I have to choose case by case when using a language or another, i.e, if I’m writing to a german customer I’ll send the links to the pages in german. So I would need a selector to change the language

    Moderator bcworkz

    (@bcworkz)

    There are a number of possible solutions. Which to use depends on what your typical workflow would look like. How do you plan to use these language specific post links? Is this the same concept as your “new link in admin dashboard opening a predefined email” topic? If not, how is it different?

    Without knowing such specifics, maybe one possible solution would be to add the links as additional content somewhere on the editor screen. You can then copy/paste whichever link is appropriate at the time. Adding additional content to your existing custom meta box would one way to accomplish this.

    Thread Starter sacconi

    (@sacconi)

    The purpose here is different: if I have to send proposals to a German customer, it would be useful to copy and paste the (short)link to the German version of the site. For me, the ideal is to have a selector to choose the language of the (short)link. So I would need a selector + a filter

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