Loading 0
Share

My Blog

Scroll Down

WPML Show untranslated products in translated categories or translate without duplicates

WPML Show untranslated products in translated categories or translate without duplicates

Hello, this particular issue is a serious problem for many e-shops as well as simple sites or blogs that use WPML.

If all you want to do is translate your product title and category titles, here's a trick:

Prerequisites: Plugins and knowledge of: WPML, WPML Translation Management, Elementor Pro, Woolentor for Elementor, WP All Import or ACF, My Custom Functions or know how to add a function to your theme.

 

Let's go:

First of all, create with Elementor pro, two beautiful store page templates and two separate product page templates (single product)

Each template represents a language. Now I'm telling you about two since we usually want one for Greek and one for English.

For more than two, additional work will be required. Ask me if you want more.

 

Let's go now to the Greek template:

In the Greek template add a Products Archive Layout (custom) element from the Woolentor plugin of Elementor with Universal Style in the Layout settings. From there on how it will look, adjust it as you want the design.

In the English template also add a Products Archive Layout (custom) element from the Woolentor plugin of Elementor, but this time in the Layout settings select the Current Theme Style (given that your theme uses to display the Woocommerce products, the template of Woocommerce. If it uses something else then in the English template do not put the woolentor products archive layout (custom), but from the classic woocommerce elements of Elementor pro choose and put the classic archives layout for products, of woocommerce).

 

After saving your two templates, now when you visit the store page, they should appear with a different design in Greek and a different one in English. Let them still have Greek tilts, nothing is wrong.

 

Now let's go to the next stage.

You need to pass the English titles to each product in a new custom field, either one by one with the ACF plugin, or in bulk via excel with the WP All Import plugin (you will see the option for a new custom field inside). I imagine you know how to do it. If not ask me and I will show you in a Youtube video. For information purposes only, custom fields are used when we want to add additional information to a product or a post, etc., for example to add a barcode to the product, etc.

The custom field must have the name "description" and the data of the custom field must be the English name of the product.

 

Now let's say you made it for all your products. The next step is to add the following function to your theme, either by editing functions.php or with the "My custom functions" plugin:

//replacement of title by NikolasLagios.com
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
function woocommerce_template_loop_product_title() {
echo '<h4 class="woocommerce-loop-product__title">' . get_post_meta( get_the_ID(), 'perigrafh', true ) . '</h4>';
}
}

 

Now that you've put the function and make sure that My custom functions is enabled (if you used that), go to your store, in the English language of the store and you'll see that woocommerce now uses the custom field "description" that we added before for the title on the products and displays the English titles. Good???

 

Now, what about categories:

If you translate the categories you will see that the main store page (the templates we made before with Elementor) works normally in both languages. But if you click on an English category (provided you've translated the categories and made sure your English store page shows a widget that shows the English categories), you'll see it's blank, showing no products, and that's because WPML thinks you don't have them translate and even if in WPML settings you choose to show untranslated products, this will not work when you visit a translated category.

So how do we display untranslated products in a translated category???

But of course using instead of translated class, untranslated ones instead.

 

So let's go ahead and delete all the translated categories and leave only the English language categories.

We go to the WPML settings (/wp-admin/admin.php?page=wpml-translation-management/menu/settings) and set the product categories to be untranslatable and also show untranslated products.

Let's go right after and create a menu (/wp-admin/nav-menus.php) and inside we will put elements (links) with all product categories where each element (link) will lead to a Greek category with the difference that at the end of the link, we will add "?lang=en", eg "/product-category/furniture/armchair-furniture/?lang=en". Of course, we will put the English name as the name of each element.

Now let's go back to elementor and make two more templates (one Greek and one English) for the Search Results. We make sure to do the same in these two templates as we did with Woolentor plugin of elementor.

Let's now go to the widgets and add to the sidebar of the eshop instead of the classic product categories, to display the menu we made.

 

You will now see that if you visit a Greek category, putting "?lang=en" at the end, it will normally display the translated products.

 

 

End of process.

 

Thanks and sorry for the fast article. I'll make sure to put it together a bit and make a video of the process at some point.

 

Best regards, Nikos..

This post is also available in: Ελληνικά

Leave a Reply

Your email address will not be published. Required fields are marked *

01.

Here you can see all the services I provide

Registration and management of domain names (website address such as www.nicolaslagios.com)

Also management of dns records (e.g. connecting the domain to a specific server, fixing email spam problems, etc.)

Also ssl renewals etc

Installation and management of web & mail server in ubuntu vps with virtualmin, plesk, cpanel

Also studying and fixing server problems.

Necessary condition, the target server meets the conditions

At the moment for new wordpress websites you can choose from ready-made themes and we change the content (no custom changes). You can buy with a fixed price by clicking here!

My team and I undertake any data bridging implementation for Wordpress, Prestashop, Opencart, Joomla platforms.

We can connect data from any source, as long as the structure is stable and there is proper documentation and briefing.

We undertake the creation, regulation and enrichment of pages for social networks: Facebook, Linkedin, Instagram (profile), Twitter (profile), Tiktok (profile).

We also undertake the first boost of your pages for quick results in followers.

We undertake the repair and maintenance of your existing wordpress website.

For more information about the services, you can read the following and return here to schedule a meeting with me: https://maxservices.gr/en/internet-services/website-services-blank/additional-website-services/