Skip to content Skip to sidebar

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

Problem:
If you're experiencing issues with the article order in BetterDocs not persisting when WPML is active, and articles losing their translated category assignments or linking to categories from both the original and translated languages, this might be due to a compatibility issue between WPML and BetterDocs.
Solution:
We recommend trying the following steps to resolve the issue:
1. Ensure you have a backup of your site.
2. Open the file

wp-content/plugins/betterdocs/includes/Core/PostType.php

.
3. Locate the following code around line 599:

if (update_term_meta($term_id, '_docs_order', $docs_ordering_data)) {<br />    wp_send_json_success(__('Successfully updated.', 'betterdocs'));<br />}

4. Replace it with:

if (update_term_meta($term_id, '_docs_order', $docs_ordering_data)) {<br />    // WPML Integration: Sync taxonomies after order change<br />    if (class_exists('SitePress') && class_exists('WPML_Term_Translation_Utils')) {<br />        $docs_array = isset($_POST['docs_ordering_data']) && is_array($_POST['docs_ordering_data'])<br />            ? array_map('intval', $_POST['docs_ordering_data'])<br />            : explode(',', $docs_ordering_data);<br />        $this->wpml_sync_posts_taxonomies($docs_array);<br />    }<br />    wp_send_json_success(__('Successfully updated.', 'betterdocs'));<br />}

5. Add the following helper function at the end of the class around line 1130, before the final '}':

/**<br /> * WPML Integration: Sync post taxonomies across translations<br /> * @param array $post_ids Array of post IDs to sync<br /> */<br />private function wpml_sync_posts_taxonomies($post_ids) {<br />    global $sitepress;<br />    if (!$sitepress || empty($post_ids)) return;<br /><br />    $sync = new \WPML_Term_Translation_Utils($sitepress);<br /><br />    foreach ($post_ids as $post_id) {<br />        $trid = $sitepress->get_element_trid($post_id, 'post_docs');<br />        if (!$trid) continue;<br /><br />        $translations = $sitepress->get_element_translations($trid, 'post_docs');<br />        $original_id = $post_id;<br /><br />        foreach ($translations as $translation) {<br />            if (isset($translation->original) && $translation->original == 1) {<br />                $original_id = $translation->element_id;<br />                break;<br />            }<br />        }<br /><br />        foreach ($sitepress->get_active_languages() as $lang => $details) {<br />            $sync->sync_terms($original_id, $lang);<br />        }<br />    }<br />}

If this solution does not resolve your issue or seems irrelevant due to updates or different circumstances, 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 with us 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: 

This topic contains 12 replies, has 0 voices.

Last updated by veikoK-2 1 week, 5 days ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
October 15, 2025 at 9:56 am #17486447

veikoK-2

Background of the issue:
I am trying to change the article order in BetterDocs using drag and drop, but the order does not persist as expected. I disabled WPML, and the issue disappeared. After rearranging all BetterDocs articles and reactivating WPML, some articles lost their translated category assignments. When I manually reassign the correct category, the article becomes linked to two categories: one from the original language and one from the translated language. I also contacted BetterDocs support, but they were unable to pinpoint the problem. If needed, I can provide access to our site’s admin panel for further investigation.

Symptoms:
The article order in BetterDocs does not persist as expected when WPML is active. Some articles lose their translated category assignments, and when reassigned, they link to two categories: one from the original language and one from the translated language.

Questions:
Why does the article order in BetterDocs not persist when WPML is active?
Why do articles lose their translated category assignments when WPML is reactivated?
Why I can't remove original language category from article (it's not visible in BetterDocs UI)?

October 15, 2025 at 6:23 pm #17488200

veikoK-2

Hi,
I posted wideo earlier toady. I'm not sure, did yo receive it or not. Will paste it once more.

hidden link

October 16, 2025 at 12:03 pm #17490137

veikoK-2

Hi,
I added some categories and translated tohem to DE.
Then I added some articles under EN and translated them to DE
Then I reoderr articles unde EN (BetterDocs UI)
And when I chek unde DE language then I can see that some articles has DE category, some are changed to EN.

I also noticed that under DE there are duplicate of EN category name (I didn't add it).
When I corrected categories under DE language manually and then went back to EN language and change the order of articles... magic happens 🙂

Regards,

October 16, 2025 at 3:14 pm #17491305

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Let me confirm a few things:

1. The error was reproduced in the Sandbox;
2. You found a solution to the error on the Sandbox;

Please let me know if I understood it correctly.

October 17, 2025 at 6:14 am #17492806

veikoK-2

Good morning,

1. Yes. I was able to reproduce the issue.

2. No, I haven't found a solution. This 'magic' messes everything up.

Regards,

October 17, 2025 at 10:33 am #17493508

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Thanks for sharing.

I would like to look at this directly on your site. For this I would need temporary access (WP-Admin and FTP) to your site, preferably to a test/staging site where the problem has been replicated if possible.

The required fields can be found below the comments section. The information you enter is private, i.e. only you and I can see it and have access to it.

I may need to replicate your website locally. To do this, I need to temporarily install a plugin called "Duplicator" or "All in One WP Migration" on your website. This will allow me to create a copy of your website and content. Once the issue is resolved, I will delete the local website. Let me know if this works for you.

IMPORTANT

Please make a backup copy of the site files and database before giving us access.

- If you do not see the wp-admin/FTP fields, this means your post and site login details are being made PUBLIC. DO NOT post your website details if you do not see the required wp-admin/FTP fields. If you do not, ask me to enable the private box. The private box looks like this:

hidden link

October 20, 2025 at 6:59 am #17497650

veikoK-2

Hi,

Sharing a copy of the database isn’t entirely straightforward. It’s possible, but requires some time due to internal bureaucracy.
I’ve reproduced the issue in the sandbox you provided—can you use the data from there?
If needed, I can prepare a step-by-step guide to help reproduce the issue.

Regards,
Veiko

October 20, 2025 at 3:27 pm #17500234

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

I understand. I escalated with the information I currently have. I'll keep you updated, thank you.

October 24, 2025 at 11:38 am #17516093

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello there,

We are still working on the issue, and have found that some adjustments are needed in the way the logic works between Betterdocs and WPML, when reordering the docs. I'll let you know when we have a concise solution or workaround.

Just as a confirmation. Can you please confirm if the issue recorded here matches is the same that you have?

hidden link

Please let me know.

October 24, 2025 at 12:39 pm #17516506

veikoK-2

Hi,

Yes. That's the issue and might be you didn't notice, below one category was changed to _EN (last article in row).

I'm using only one category per article. And on all of cases selected category is a subcategory of something...

Regards,
Veiko

wpml.png
October 27, 2025 at 11:33 am #17521656

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello there,

Thank you for waiting. Our devs noticed that this specific feature is not fully compatible with WPML: When you reorder docs in BetterDocs, translated posts get wrong category IDs (English categories instead of German). BetterDocs doesn't notify WPML about changes, so category translations desynchronize.

They've provided us with a workaround. Please ensure to have a backup and:

1. Open the file wp-content/plugins/betterdocs/includes/Core/PostType.php
2. Find (around line 599):

if ( update_term_meta( $term_id, '_docs_order', $docs_ordering_data ) ) {
    wp_send_json_success( __( 'Successfully updated.', 'betterdocs' ) );
}

3. Replace it with:

if ( update_term_meta( $term_id, '_docs_order', $docs_ordering_data ) ) {
    // WPML Integration: Sync taxonomies after order change
    if ( class_exists( 'SitePress' ) && class_exists( 'WPML_Term_Translation_Utils' ) ) {
        $docs_array = isset( $_POST['docs_ordering_data'] ) && is_array( $_POST['docs_ordering_data'] ) 
            ? array_map( 'intval', $_POST['docs_ordering_data'] )
            : explode( ',', $docs_ordering_data );
        $this->wpml_sync_posts_taxonomies( $docs_array );
    }
    
    wp_send_json_success( __( 'Successfully updated.', 'betterdocs' ) );
}

4. Add helper function at end of class (around line 1130). Add before the final '}':

/**
 * WPML Integration: Sync post taxonomies across translations
 * @param array $post_ids Array of post IDs to sync
 */
private function wpml_sync_posts_taxonomies( $post_ids ) {
    global $sitepress;
    if ( ! $sitepress || empty( $post_ids ) ) return;

    $sync = new \WPML_Term_Translation_Utils( $sitepress );
    
    foreach ( $post_ids as $post_id ) {
        $trid = $sitepress->get_element_trid( $post_id, 'post_docs' );
        if ( ! $trid ) continue;
        
        $translations = $sitepress->get_element_translations( $trid, 'post_docs' );
        $original_id = $post_id;
        
        foreach ( $translations as $translation ) {
            if ( isset( $translation->original ) && $translation->original == 1 ) {
                $original_id = $translation->element_id;
                break;
            }
        }
        
        foreach ( $sitepress->get_active_languages() as $lang => $details ) {
            $sync->sync_terms( $original_id, $lang );
        }
    }
}

Let me know how it goes.

October 27, 2025 at 7:38 pm #17523622

veikoK-2

Hello,

Thanks — the provided code seems to resolve the issue based on initial quick tests. However, since the fix was applied directly to the BetterDocs codebase, it will likely be overwritten with the next BetterDocs update.

Do you plan to communicate this issue to the BetterDocs team, or should I follow up with them?

I actually reached out to BetterDocs support earlier, but unfortunately they weren’t able to resolve the issue.

Regards,
Veiko

October 28, 2025 at 9:46 am #17525326

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Thank you for your feedback. Precisely, we will get in touch with the Betterdocs team as soon as we can, to notify about the change in compatibility. Until then, unfortunately, if there are any updates, the fix will need to be reimplemented.

Thank you for your patience so far.

October 28, 2025 at 2:07 pm #17526449

veikoK-2

Thanks. Will keep it in minds.