[Waiting for user confirmation] Can't see Learndash courses in english
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.
WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Hi Andreas, I'm not entirely clear on what you're trying to do, but if this won't cause any issues or blocks on the main site, feel free to proceed as you prefer!
Sorry, Andreas, I had the code analyzed by ChatGPT to understand if it could affect my Italian SEO, and this is what it says:
Analyzing the new code provided, it appears to address the issue in a robust manner. However, there are some critical aspects that need to be reviewed to ensure it fully meets your requirements. Let’s break it down:
What the new code does:
Handles the translated slug for the custom post type (sfwd-courses):
It uses the wpml_get_translated_slug filter to fetch the translated slug based on the current language.
It provides a fallback to retain the original slug (e.g., i-nostri-corsi) if a translation is not available.
Builds the permalink:
Combines the translated slug, the category term (ld_course_category), and the post name (post_name).
Avoids errors with fallbacks and sanitization:
Ensures each component of the permalink is properly defined, avoiding malformed URLs or double slashes (//).
Potential issues or uncertainties:
Italian language:
While the code seems to handle Italian correctly, it doesn’t explicitly ensure that the original slug /i-nostri-corsi/ remains unchanged for Italian courses. If wpml_get_translated_slug returns a different slug for Italian, it might unintentionally alter the permalink.
Incomplete slug translation:
The fallback uses $default_slug (i-nostri-corsi) if no translation is found. However, this might not be sufficient in edge cases (e.g., if the translated slug is empty or differs from what you expect).
SEO impact:
The code should preserve existing permalinks in Italian, but if the slug changes for any reason, it could break existing URLs.
Expected outcomes:
If your goal is to:
Italian language: Keep the original /i-nostri-corsi/ slug intact.
Other languages: Translate the slug appropriately based on WPML settings.
The code will work only if:
The Italian slug (i-nostri-corsi) is explicitly preserved.
WPML is correctly configured to handle translations for the other languages
Possible improvements:
To ensure the Italian slug is never altered, you can explicitly enforce it in the code:
if ( $language_code === 'it' ) {
$translated_slug = $default_slug; // Keep the original slug for Italian
} else {
$translated_slug = apply_filters( 'wpml_get_translated_slug', $default_slug, 'sfwd-courses', $language_code, 'post' );
}
This ensures that for Italian, the slug always remains i-nostri-corsi, regardless of WPML’s configuration.
Yes, this is correct and the findings of ChatGPT appear expected..
If you change the original Italian slug, this snippet will not longer work. Further, it is expected that WPML changes the slug accordingly to use the translated slugs in other languages.
I need to point out again, that I did already way more than expected here.
Custom code requestes are not covered by our support policy and our supporters are not supposed to provide custom code solution.
You could consult ChatGPT about how to obtain the original CPT slug dynamically and also ask it to handle edge cases in which a translation does not exists. It should come up with a working solution.
If you would like someone else to optimize your custom code, then I need to ask you reach out to on of our contractors: https://wpml.org/contractors/