Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 4 replies, has 0 voices.

Last updated by Osama Mersal 21 hours, 58 minutes ago.

Assisted by: Osama Mersal.

Author Posts
February 24, 2025 at 2:53 pm #16741681

denyD

Background of the issue:
I'm using WPML with Learndash and Elementor on my site hidden link. I am trying to edit the course content in the second language using Elementor.

Symptoms:
When I try to edit the course content with Elementor, it gives me this error: 'the preview could not be loaded'.

Questions:
How can I fix the error 'the preview could not be loaded' when editing with Elementor?

February 24, 2025 at 4:00 pm #16742043

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

Please log in to this hidden link">sandbox site and create a test course with its translation.

After that, please try to replicate the issue. If the issue is replicable, please let me know to check it and consult our compatibility team.

Kindly note that the sandbox site has WPML, Elementor, and LearnDash installed.

Best regards,
Osama

February 24, 2025 at 5:07 pm #16742398

denyD

I tried, and it seems to work. But I'm not sure if I replicated the same steps. Could it be that the reason is that the content of the course in the original language is translated via WPML and therefore can no longer be translated with Elementor?

Additionally, I first created the course in the original language (Italian) and then created the English translation, but I don't need the Italian course—it shouldn't exist. So, is it mandatory to have a course in the original language in order to have one in the second language (English)?

Moreover, I can tell you that if I create a course in the second language (English) from scratch, without having a translation from Italian, the error does not appear. However, Elementor simply does not open—it just keeps loading indefinitely.

February 24, 2025 at 5:12 pm #16742407

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

1) Thanks for your update. Could you please check if the issue persists in a minimal environment by following these steps?

1- Deactivate all the plugins except those active ones on the sandbox site.
2- Switch to a WordPress default theme like Twenty Twenty-one.
3- Create a course directly in English
4- Edit it directly using Elementor

If the issue is gone, activate them one by one to see which one is causing an interaction issue.

❌ Please backup your database before the above test ❌

2) Answers to your questions:

* Is it mandatory to have a course in the original language in order to have one in the second language (English)?
- No, you can add courses to English directly.

* Could it be that the course's content in the original language is translated via WPML and, therefore, can no longer be translated with Elementor?
- It might be the reason, but it might be that the English course is corrupted in the database.

Best regards,
Osama

February 25, 2025 at 10:54 am #16745051

denyD

I'm talking with Elementor support too, here what they said:

"I am also unable to edit that test course in English. I deactivated all plugins except Elementor, Learndash, and WPML, but the issue persists.

It appears there is some kind of conflict between WMPL, Learndash, and Elementor. There are no errors in the console. The post content widget is in the template (which usually causes this error), so it should work. In this case, the translated courses do not have post content, which is why Elementor is not able to open it in the editor. Is this something that can be checked by the developers?"

As you can see, they tried to deactivate all plugins but nothing changed.
If they try to add a new course in English, they get a 404 error.
These errors occur only with English courses, and the reason is that Elementor cannot generate the course content, while the WordPress editor can.

February 25, 2025 at 11:12 am #16745162

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your update. I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please backup your database and website ❌

✙ I need your permission to deactivate and reactivate the plugins and themes and change site configurations. This is also why the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

Best regards,
Osama

February 25, 2025 at 12:26 pm #16745557

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access details. I deactivated all the plugins except WPML, Elementor, and LearnDash. After that, I activated the Twenty Twenty-One theme to replicate the sandbox installation.

Then, I created a test course in English, which worked correctly with Elementor. (hidden link)

Please activate your plugins one by one and check the issue after each activation.

Best regards,
Osama

February 25, 2025 at 1:55 pm #16746206

denyD

Ok i don't need to activate the plugins. The problem is inside my child theme "gimarbeauty". Can u help me to find the problem?

February 25, 2025 at 2:01 pm #16746213

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

The issue happens because of the following function.

unction change_link_corsi( $permalink, $post ) {
    if ( $post->post_type === 'sfwd-courses' ) {
        $resource_terms = get_the_terms( $post, 'ld_course_category' );
        $term_slug = '';

        // Get the current language code
        $language_code = apply_filters( 'wpml_current_language', null );

        // Dynamically retrieve the slug for the current language
        $default_slug = 'i-nostri-corsi'; // Default slug in the primary language
        $translated_slug = apply_filters( 'wpml_get_translated_slug', $default_slug, 'sfwd-courses', $language_code, 'post' );

        // Fallback to default slug if translation is missing
        $translated_slug = $translated_slug ?: $default_slug;

        if ( ! empty( $resource_terms ) ) {
            foreach ( $resource_terms as $term ) {
                if ( $term->slug === 'featured' ) {
                    continue;
                }
                $term_slug = $term->slug;
                break;
            }
        }

        // Build the final permalink
        $permalink = trailingslashit( get_home_url() ) . $translated_slug . '/' . ( $term_slug ? $term_slug . '/' : '' ) . $post->post_name;
    }
    return $permalink;
}
add_filter( 'post_type_link', 'change_link_corsi', 10, 2 );

After commenting it in the functions.php file, Elementor opened correctly.

Best regards,
Osama

February 25, 2025 at 2:05 pm #16746236

denyD

What you mean for "After commenting it"? What should i do to fix it even on the live site? Because that function is needed to set the correct permalinks for the English courses, as the default ones from LearnDash are not suitable.

February 25, 2025 at 2:14 pm #16746313

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

I'm afraid custom coding is out of our support scope. Kindly check the support policy.

I suggest it be changed to something like this:

function change_link_corsi( $permalink, $post ) {
    if ( $post->post_type === 'sfwd-courses' ) {

        // Prevent permalink modification when editing in Elementor
        if ( isset( $_GET['elementor-preview'] ) || ( defined( 'ELEMENTOR_VERSION' ) && \Elementor\Plugin::$instance->editor->is_edit_mode() ) ) {
            return $permalink;
        }

        $resource_terms = get_the_terms( $post, 'ld_course_category' );
        $term_slug = '';

        // Get current language code
        $language_code = apply_filters( 'wpml_current_language', null );

        // Default slug in primary language
        $default_slug = 'i-nostri-corsi';

        // Get translated slug using WPML's correct method
        $translated_slug = apply_filters( 'wpml_translate_single_string', $default_slug, 'URL Slugs', 'course_slug_' . $language_code );

        // Fallback if translation is missing
        $translated_slug = $translated_slug ?: $default_slug;

        // Get WPML-compatible home URL and ensure it's properly formatted
        $home_url = rtrim( apply_filters( 'wpml_home_url', get_home_url() ), '/' );

        if ( ! empty( $resource_terms ) ) {
            foreach ( $resource_terms as $term ) {
                // Skip 'featured' category to get the primary one
                if ( $term->slug === 'featured' ) {
                    continue;
                }
                $term_slug = $term->slug;
                break;
            }
        }

        // Construct final permalink while preventing double slashes
        $permalink = $home_url . '/' . $translated_slug . ( $term_slug ? '/' . $term_slug : '' ) . '/' . $post->post_name;
    }
    return $permalink;
}
add_filter( 'post_type_link', 'change_link_corsi', 10, 2 );

Please note that this custom code is a courtesy and is not officially supported by the WPML team. Please test it in a staging environment before applying it to a live site.

Please contact one of our contractors if you need more help regarding this function.

Best regards,
Osama

February 25, 2025 at 3:02 pm #16746590

denyD

Sorry but, what you did to make it work properly?

February 25, 2025 at 3:06 pm #16746602

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Please check the comments added to the function. Here is what's added or changed:

* Prevent permalink modification when editing in Elementor
* Get translated slug using WPML's correct method
* Get a WPML-compatible home URL and ensure it's properly formatted

Best regards,
Osama

February 25, 2025 at 4:01 pm #16746884

denyD

Unfortunately, the code does not work. The snippet you modified is meant to change the permalink from "i-nostri-corsi" to "courses." This code was provided by you because the "i-nostri-corsi" permalink is not LearnDash's default, and it is necessary to set the correct permalink; otherwise, the courses will not be visible. With the changes you made, you can see that the permalink for the courses in English has changed, and the courses page is no longer visible. Unfortunately, this is something only you can help me resolve.

February 25, 2025 at 4:05 pm #16746900

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Please get in touch with the developer who wrote this function or hire a contractor to make the code compatible with WPML, Elementor, and LearnDash.

My changes are suggestions, not tested code, as supporting custom code is outside our support scope.

Best regards,
Osama