Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is using the Unlimited Elements Post Grid in Elementor to display posts via Manual Selection. In the primary language, adding Post IDs or Post Names works correctly, but these do not display in the Advanced Translation Editor (ATE) for translation, causing no posts to display in the second language. Editing the post in the second language and adding Italian post IDs or Post Names works until the ATE is accessed again, after which the posts revert to English Post IDs or Titles.
Solution:
We recommend inserting the following custom PHP code into your theme's functions.php file to ensure that post IDs are correctly translated and maintained across language changes:

// WPML Workaround for compsupp-7445<br />add_filter('elementor/frontend/before_render', 'wpml_compsupp7445_filter_ucaddon_post_grid');<br /><br />function wpml_compsupp7445_filter_ucaddon_post_grid($element) {<br />    if ('ucaddon_post_grid' !== $element->get_name() ) {<br />        return;<br />    }<br />    $settings = $element->get_settings();<br />    if (isset($settings['post_list_manual_select_post_ids']) && is_array($settings['post_list_manual_select_post_ids'])) {<br />        foreach ($settings['post_list_manual_select_post_ids'] as $key => $id) {<br />            $post_type = get_post_type($id);<br />            if (!$post_type) {<br />                continue;<br />            }<br />            $id = apply_filters('wpml_object_id', $id, $post_type, true);<br />            unset($settings['post_list_manual_select_post_ids'][$key]);<br />            $settings['post_list_manual_select_post_ids'][] = $id;<br />        }<br />        $element->set_settings('post_list_manual_select_post_ids', $settings['post_list_manual_select_post_ids']);<br />    }<br />    if (isset($settings['post_list_manual_post_ids_dynamic'])) {<br />        if (is_string($settings['post_list_manual_post_ids_dynamic'])) {<br />            $settings['post_list_manual_post_ids_dynamic'] = explode(',', $settings['post_list_manual_post_ids_dynamic']);<br />        }<br />        if (is_array($settings['post_list_manual_post_ids_dynamic'])) {<br />            foreach ($settings['post_list_manual_post_ids_dynamic'] as $key => $id) {<br />                $post_type = get_post_type($id);<br />                if (!$post_type) {<br />                    continue;<br />                }<br />                $translated_id = apply_filters('wpml_object_id', $id, $post_type, true);<br />                $settings['post_list_manual_post_ids_dynamic'][$key] = $translated_id;<br />            }<br />            $element->set_settings('post_list_manual_post_ids_dynamic', $settings['post_list_manual_post_ids_dynamic']);<br />        }<br />    }<br />}

If this solution does not resolve your issue or seems irrelevant due to updates or differences in your setup, we 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 with us.

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: 

This topic contains 6 replies, has 2 voices.

Last updated by Kor 5 months ago.

Assisted by: Kor.

Author Posts
June 25, 2024 at 2:21 pm #15821711

justinK-16

Background of the issue:
We use the Unlimited Elements Post Grid to display 3 posts via Manual Selection. In the primary language, if I add either a Post ID or Post Name to the Post Query Fields, they display correctly. These do not display in the ATE for translation (neither for the Post IDs nor Post Names). Therefore, no posts are displayed in the second language. If I edit the post in the second language and add in the Italian post IDs or Post Names (I have tried both options), all works and displays correctly UNTIL I make an edit to the original language post and open the ATE. Upon saving the ATE, the Italian posts revert to English Post IDs or Titles (and again do not display).

Symptoms:
Post IDs or Post Names do not display in the ATE for translation, causing posts not to display in the second language. After editing the original language post and saving in ATE, the Italian posts revert to English Post IDs or Titles.

Questions:
Does the Widget need to be registered?
Is there any specific documentation for translating Unlimited Elements Post Grid with WPML?

June 25, 2024 at 3:29 pm #15822642

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your patience.

You can access the sandbox site here: hidden link . I've installed WPML plugins to assist you. Please reproduce the issue and provide me with the details. Once I have them, I'll proceed to file a report for further escalation.

June 26, 2024 at 8:38 am #15831284

justinK-16

Hi Kor

Sorry for the delay.

Ok, I have installed:
Elementor (I didn't bother with Elementor Pro - I didn't think it was necessary but let me know if you need it)
Unlimited Elements

I created:
1 page with the Post Grid element
3 posts

Translated all 4 into Italian

In Edit with Elementor - Edit Post Grid
I have not changed ANY settings/styles etc for the element EXCEPT:
Edit Post Grid > Content > Posts Query> Post Source - Changed to Manual Selection
Also, I added the 3 posts to the "Search And Select Posts" field.

Now if you view the post:
English - Posts appear
Italian - No posts appear (makes sense as there has been no option to translate posts in the ATE or relate secondary language posts anywhere that I am aware of.

So next step:
In the WP Dashboard > Pages
Switch to Italian language
Select the Page
Add the Italian versions of the Posts to the "Search and Select Posts" field.
Save/update page

Now if you view the post:
English - Posts appear
Italian - Posts appear in Italian

Back in the primary language - At any point from now, if the ATE is accessed and you click on Complete Translation the POsts disappear when the page is viewed in Italian.

Also to note:
If we switch to Italian and Edit With Elementor, you will see that the "Search And Select Posts" field has been overwritten with the English Post versions again - I guess they are being copied and overwritten.

I would prefer to use the "Or Select Post IDs" field - I have not tested it here in the sandbox but on our site, the exact same situation occurs as with using "Search And Select Posts".

Please let me know if you need anything else.

Thank you
Justin

June 26, 2024 at 1:26 pm #15834335

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've escalated this to our 2nd Tier Support for further investigation and I will come back to you once I've feedback.

June 28, 2024 at 7:23 am #15849893

justinK-16

Hi Kor

Thank you, I appreciate it.

I am not being pushy at all, just need to plan our workflow and was wondering about an eta

Does this type of think usually take a day, a week, or more to hear back?

June 28, 2024 at 4:26 pm #15853340

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

We do have a similar case with Unlimited Elements but we have a fix for Post Carousel and not Post Grid https://wpml.org/errata/unlimited-elements-for-elementor-post-carousel-doesnt-fetch-translated-posts/ .

Our 2nd Tier Support will recheck and will revert back to us as quickly as possible.

July 2, 2024 at 9:53 am #15874090

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

We have a solution for you and kindly insert the custom PHP code below into your theme's functions.php file. I've tested on our sandbox site here hidden link and it works fine now hidden link

// WPML Workaround for compsupp-7445
add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7445_filter_ucaddon_post_grid');
 
function wpml_compsupp7445_filter_ucaddon_post_grid($element) {
    if ( 'ucaddon_post_grid' !== $element->get_name() ) {
        return;
    }
 
    $settings = $element->get_settings();
 
    if ( isset( $settings['post_list_manual_select_post_ids'] ) && is_array( $settings['post_list_manual_select_post_ids'] ) ) {
        foreach ( $settings['post_list_manual_select_post_ids'] as $key => $id ) {      
 
            $post_type = get_post_type( $id );
 
            if ( ! $post_type ) {
                continue;
            }
 
            $id = apply_filters( 'wpml_object_id', $id, $post_type, true );
 
            unset($settings['post_list_manual_select_post_ids'][$key]);
            $settings['post_list_manual_select_post_ids'][] = $id;
        }
 
        $element->set_settings( 'post_list_manual_select_post_ids', $settings['post_list_manual_select_post_ids'] );
    }
	
    if (isset($settings['post_list_manual_post_ids_dynamic'])) {
        // Check if the IDs are in a string and convert them to an array
        if (is_string($settings['post_list_manual_post_ids_dynamic'])) {
            $settings['post_list_manual_post_ids_dynamic'] = explode(',', $settings['post_list_manual_post_ids_dynamic']);
        }

        // Proceed only if it's an array
        if (is_array($settings['post_list_manual_post_ids_dynamic'])) {
            foreach ($settings['post_list_manual_post_ids_dynamic'] as $key => $id) {
                $post_type = get_post_type($id);
                if (!$post_type) {
                    continue;
                }
                $translated_id = apply_filters('wpml_object_id', $id, $post_type, true);
                $settings['post_list_manual_post_ids_dynamic'][$key] = $translated_id;
            }
            $element->set_settings('post_list_manual_post_ids_dynamic', $settings['post_list_manual_post_ids_dynamic']);
        }
    }	
}
July 2, 2024 at 12:49 pm #15875339

justinK-16

Kor thank you so much, it all appears to be working perfectly.

You're amazing, I really appreciate your assistance with this!

Thanks again