This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing issues with the primary category not being correctly represented in the Language Switcher for Spanish URLs, leading to incorrect URL structures on page load, particularly after updating to version 4.7.4, this might be due to a compatibility issue with the Only Top Category option of the Grid Post widget from the Unlimited Elements for Elementor (Premium) plugin.
Solution:
First, we recommend replicating the issue on a clean installation to confirm it's a compatibility issue. Here are the steps:
1. Install Unlimited Elements for Elementor (Premium) on a clean WordPress installation with Elementor, Yoast, WPML, and all necessary WPML add-ons.
2. Create the same situation and try to replicate the issue.
Additionally, there is a workaround provided by our compatibility team:
1. Open the file
.../wp-content/plugins/unlimited-elements-for-elementor/provider/provider_params_processor.class.php
2. Locate the
getPostMainCategory
function on line 574.
3. Replace the existing code with the new code provided, which includes a WPML filter to ensure the primary category ID is correctly translated.
4. Clear Elementor's cache by going to "Elementor > Tools > Clear Files & Data" and ensure the translation is 100% complete.
If these steps do not resolve your issue, or if the solution seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum for further assistance.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Tagged: Exception
This topic contains 14 replies, has 0 voices.
Last updated by justinK-16 8 months, 3 weeks ago.
Assisted by: Christopher Amirian.
| Author | Posts |
|---|---|
| May 12, 2025 at 9:41 am | |
|
justinK-16 |
Background of the issue: Go back a step to - hidden link. However it should be: hidden link. So the last couple NEW Posts created and translated - the primary Category is not correctly represented in the Lang Switcher, and therefore on page load. Symptoms: Questions: |
| May 12, 2025 at 10:58 am #17022450 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Welcome to WPML support. Please get back to us with the result of the: 1. Clean installation of WordPress, check for the Ultimate Elementor addon for the grid options to test the inconsistent categories of the Italian version. 2. Check for possible plugins and theme conflicts for the unusual redirection issue for the Spanish version: hidden link Thanks. |
| May 12, 2025 at 12:28 pm #17022934 | |
|
justinK-16 |
Hi Christopher The issue I would really like to address and solve is the Spanish URL appearing with a completely different category in the URL ONLY IN THE LANGUAGE SWITCHER, as this is a problem that has only recently arisen. The URL created and that appears in the Unlimited Elements post grid is with the correct category (again, just the language switcher displays a different category in the URL). It is not a redirect issue, it is choosing to display another Category (albeit it is one of the other categories selected in WordPress Edit Post - but just not the Primary one). The Primary Category has always been the one to appear in the URL for all posts in all languages until the last 2 posts - but again only in Spanish the rest are appearing as they should. Is it possible to focus on fixing this first? The Post Grid issue is something I can live with for now - but am happy to also add to the sandbox if you want to test for compatibility. |
| May 12, 2025 at 3:06 pm #17023751 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Sure for that we will indeed need you to provide us with a staging / copy version of the website so we can do troubleshooting. The first step would be to check if the same thing happens on a minimal installation or not, according to the steps given in the chat. You can set the next reply to provide us with the staging version of the website so we can do troubleshooting without the fear of ruining a live website. Thanks. |
| May 19, 2025 at 8:44 am #17047257 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Thank you for the login information. I tried to check the primary category issue but as soon as I deactivated some plugins there is a fatal error. Most probably because your Child theme uses some code that depends on one of those plugins. Would you please access the website folders and rename the: wp-content/themes/onelisting-pro-child/ folder to something else? It will force the child theme to be deactivated and a default theme used. That should bring back the website so I can continue the troubleshooting. Thanks. |
| May 19, 2025 at 4:25 pm #17049605 | |
|
justinK-16 |
Hi Christopher Renamed and all working again. Sorry, I forgot to tell you that if you deactivate "Admin and Site Enhancements (ASE) Pro" - it will do that. Also, when that is deactivated, it will change the admin URL... All other credentials to log in remain the same. If you don't know the old admin URL just let me know so I can provide it. |
| May 20, 2025 at 9:13 am #17051609 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Thank you for the info. I managed to access the website and after troubleshooting it seems to be a compatibility issue between the Only Top Category option of the Grid Post widget of the Unlimited Elements for Elementor (Premium) plugin. I created a video explaining why that is what I concluded: hidden link To be able to report the compatibility issues we need to replicate the issue on a clean installation. hidden link Kindly follow the steps below: - Install Unlimited Elements for Elementor (Premium). This will help us to report the probable issue to the compatibility team and solve the possible problem faster. I also suggest that you contact the plugin developers and report the issue. Thanks. |
| May 22, 2025 at 6:38 pm #17063327 | |
|
justinK-16 |
Hi Christopher Ok, i added: Unlimited Elements Plugin 3 Posts - Set the primary category and selected an additional category Translated in the ATE also translated the Taxonomies in the ATE (normally one would do it in Taxonomies Translations but it appeared in the ATE so I translated them there). The issue still happens in this clean installation. it appears to ignore the primary category and display the category in preference of alphabetical order hence you will notice on the 3rd post red changed to Black when switching to FR. Also, if you set the primary category to Green instead of Blue (in English) for the middle post you will see it change also. Let me know if you need anything else |
| May 25, 2025 at 3:57 pm #17070149 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Thank you very much. I reported this to the compatibility team. Meanwhile, please contact the plugin developers and inform them about the issue. I will get back to you as soon as I have news. It might take time. Thanks. |
| May 28, 2025 at 12:01 pm #17083304 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, There is a workaround suggested below by the compatibility team: - Open the .../wp-content7plugins7unlimited-elements-for-elementor7provider7provider_params_processor.class.php file - Look for the getPostMainCategory function on line 574 - Replace:
/**
* get post main category from the list of terms
*/
private function getPostMainCategory($arrTerms, $postID){
//get term data
if(count($arrTerms) == 1){ //single
$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
return($arrTermData);
}
$arrMeta = UniteFunctionsWPUC::getPostMeta($postID,true);
$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "_yoast_wpseo_primary_category");
if(empty($mainCategoryID))
$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "rank_math_primary_category");
if(empty($mainCategoryID)){
unset($arrTerms["uncategorized"]);
$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
return($arrTermData);
}
- With:
/**
* get post main category from the list of terms
*/
private function getPostMainCategory($arrTerms, $postID){
//get term data
if(count($arrTerms) == 1){ //single
$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
return($arrTermData);
}
$arrMeta = UniteFunctionsWPUC::getPostMeta($postID,true);
$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "_yoast_wpseo_primary_category");
if(empty($mainCategoryID))
$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "rank_math_primary_category");
// WPML Workaround for compsupp-8023
if (!empty($mainCategoryID)) {
$mainCategoryID = apply_filters('wpml_object_id', $mainCategoryID, 'category', true);
}
if(empty($mainCategoryID)){
unset($arrTerms["uncategorized"]);
$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
return($arrTermData);
}
- Go to Elementor's cache in "Elementor > Tools > Clear Files & Data and clear Elementor Cache Please tell us if that worked for you. Thanks. |
| June 2, 2025 at 6:48 am #17096405 | |
|
justinK-16 |
Hi Christopher I am away for a week and will test this early next week and get back to you. If this does work, i assume when the plugin is updated it will be overwritten? Is it possible to extend the open time for this ticket so i have time to implement, check and get back to you? Thanks |
| June 2, 2025 at 7:10 am #17096429 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Ok sure, that is correct, if the plugin is updated it will be overwritten. We need your confirmation first and then we will contact the developers of the plugin and inform them about the issue. After that, it is up to them to implement a solution. It might not necessarily be a solution like ours as they might have other considerations regarding their codebase. Thanks. |
| June 9, 2025 at 1:07 pm #17118553 | |
|
justinK-16 |
Hi Christopher That seemed to work just fine, i did not even need to do a post/page update and translation - the Categories automatically updated on refresh and now match for all languages. So i can confirm after checking many pages/posts all is now working with your workaround. I will get in touch with Unlimited Elements and let them know also. Thanks for your help with all this. |
| June 9, 2025 at 3:07 pm #17118902 | |
|
Christopher Amirian WPML Supporter since 07/2020
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Thank you for informing us. |
| June 10, 2025 at 3:07 pm #17122548 | |
|
justinK-16 |
Just letting you know, Unlimited Elements responded and said it was interesting and that he would look into it and implement a fix. Thanks for your help with this. |