[Resolved] WPML and BetterDocs does not like to work together
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
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.
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)?
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 🙂
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:
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.
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?
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):
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.
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.