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)

Tagged: 

This topic contains 0 replies, has 1 voice.

Last updated by Osama Mersal 9 hours, 26 minutes ago.

Assisted by: Osama Mersal.

Author Posts
January 3, 2025 at 9:05 pm #16562571

ericH-23

Background of the issue:
I am working on a site under development using WPML and Buddyboss and WP Jobmanager. I want to ensure that when a job is shown in a translated/duplicated language version, the related job area should not display the same job again.

Symptoms:
When I switch to a translated language version of a job, the same job is shown in the related jobs section, which should not happen.

Questions:
Why is the same job appearing in the related jobs section when viewed in a translated language?
How can I prevent jobs from appearing in the related jobs section in translated languages?

January 5, 2025 at 10:56 am #16564289

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.

1) Please log in to this hidden link">sandbox site and install the WP Job Manager plugin.

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

2) Could you please share your Debug information with me?
You can read a detailed explanation about it here. (http://wpml.org/faq/provide-debug-information-faster-support)
The debug info will give me much information about how your site is configured.

Best regards,
Osama

January 6, 2025 at 7:03 pm #16567409

ericH-23

Hi,
I added all needed plugins in the sandbox and have shown the error here:

FR: shown job is also at related
hidden link

EN: shown job is NOT at related
hidden link

Please see the attached screenshot.

It is needed, that in other languages also the same job is not shown under reletated jobs.

Thanks, kind regards
Eric

PS: debug I cancelled, because the error is shown in sandbox, so it has nothing to with my site especially

Bildschirmfoto 2025-01-06 um 19.56.20.png
January 7, 2025 at 9:57 am #16568765

Osama Mersal
Supporter

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

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

Hi,

Thanks for replicating the issue on the sandbox site. Please check if the issue is fixed in the French language jobs.

Best regards,
Osama

January 16, 2025 at 8:34 am #16600244

ericH-23

Hi,
Yes, the link hidden link shows now not the same job at the related jobs sections. Good!
What did you do and how I can take this over in my site?
Thanks, kind regards
Eric

January 16, 2025 at 8:38 am #16600317

Osama Mersal
Supporter

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

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

Hi Eric,

Thanks for your confirmation. Please check the following steps:

1- Edit the /buddyboss theme/template-parts/related-jobs.php
2- Add the following code after line 12

// Get the current post ID
        $current_post_id = get_queried_object_id();
		
		// Initialize exclusion array with the current post ID
        $exclude_ids = array( $current_post_id );

        // Get the translated version of the current post in all languages
        if ( function_exists( 'wpml_object_id_filter' ) ) {
            global $sitepress;
            $languages = $sitepress->get_active_languages();
            foreach ( $languages as $lang_code => $lang_info ) {
                $translated_id = wpml_object_id_filter( $current_post_id, 'post', true, $lang_code );
                if ( $translated_id && ! in_array( $translated_id, $exclude_ids ) ) {
                    $exclude_ids[] = $translated_id;
                }
            }
        }

        // Remove excluded IDs from the posts array
        $posts_array = array_diff( $posts_array, $exclude_ids );

3- Replace the following code

'post__in' => $posts_array,
'post__not_in' => array( $post->ID ),

With

'post__in' => $posts_array,

Best regards,
Osama

January 17, 2025 at 2:39 pm #16606734

ericH-23

Hi,
Thanks, I added the code and unfortunately have this result:

1) before in EN = no related jobs
2) before in DE = the same job below as related
3) after the new code = all test jobs shown at related

3) all different category jobs are shown here at related, but they are not related

Can you please check this? Could be that now the filter doesn't work anymore, so that not only "related jobs" are shown. I made a test and added a job with totally other text and category etc. and all the other jobs are shown below. So I think, now the related filter is not working anymore.

Thanks, kind regards
Eric

after at all languages.png
before in DE.png
before in EN.png
January 18, 2025 at 10:32 am #16608888

Osama Mersal
Supporter

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

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

Hi Eric,

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

January 21, 2025 at 11:38 am #16618131

Osama Mersal
Supporter

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

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

Hi Eric,

Would it be possible to run the following test on the staging site?

1- Deactivate all the plugins except those active ones on the sandbox site.
2- Switch to the parent theme.

❌ Please backup your database before performing the above test ❌

Best regards,
Osama