• Translation of slugs/ head title tags working

    • Product Category (WooCommerce)
    • Product Page (WooCommerce)
    • Product Tag (WooCommerce)

    Translation of slugs/ head title tags NOT working

    • Shop/ Cart/ My Account (WooCommerce)
    • Any custom page created via pages > Ad New
      I can totally create a second content-version for another language, which will show on the frontend just fine, but whether slugs nor the head title tag will show translated.
      If I switch to another language in “wp-admin/post.php?post=X&action=edit” and go to settings > page (on the right side of the screen) the URL shows the default-language. Once I hover over it, it shows the translated version of language 2. However, it doesn’t work in the frontend.

    Is this some kind of bug, or do I need to adjust any setting in order to get it right? I’m totally lost right now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter muckaveli

    (@muckaveli)

    I’ve found the solution for the slugs of perma pages

    The translation – that stems from the translation page title – will be shown inside a certain modal, but not displayed on the front-end unless you’ve manually edited it for once and then hit “update”!

    Here is the process

    • Chose a page from your back-end pages menu and go to “edit”
    • Chose your second language from the top menu
    • Make sure the top menu is set to “Settings”
    • Go to the menu settings on the right side that says “page” and look for the field title “URL”
    • This URL might not show a translated version, however if you CLICK on that URL and a modal will open up…
    • Here it will show already translated content in the “Permalink” field, however you must click in the box, make whatever edit (like delete the last character and type it back in), then hit “X” to close the modal
    • Now you’ll see the URL updated to your translation. The /sublanguage/ folder is not being displayed, but don’t worry about that, it will be shown in the front-end.
    • Now, hit “Update” on the top menu to save your page
    • Wait a couple of minutes for your server/cache to do it’s magic, and voilà! The slug is now being properly translated!
    Thread Starter muckaveli

    (@muckaveli)

    I’ve found a solution for the title-tags

    Hey Maxime, it seems that whatever other plugin overwrites the settings of sublanguage for the page titles. Your code works, it’s priority just isn’t high enough. I have fixed that by adding the priority “999999” (yes, that’s 6 x 9) to this code. Now it works like a charm!

    One can add the code below to the functions.php or use a plugin to stay update-safe.

    <?php
    function custom_title_tag( $title ) {
       if ( is_front_page() ) {
          $title = '';
       } elseif ( is_singular() ) {
          $title = single_post_title( '', false );
       }
       return $title;
    }
    add_filter( 'pre_get_document_title', 'custom_title_tag', 999999 );
    ?> 
    • This reply was modified 1 year, 5 months ago by muckaveli.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Slugs/ title tags remain untranslated’ is closed to new replies.