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 – 13:00 5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Argentina/Buenos_Aires (GMT-03:00)

This topic contains 3 replies, has 0 voices.

Last updated by Otto 3 months, 1 week ago.

Assisted by: Otto.

Author Posts
February 5, 2025 at 6:29 am #16669042

emmanuelD-13

Background of the issue:
I am trying to implement a live search module on my website, allowing users to get suggested search results in the correct language. The website's main language is French, and it is translated into English and Spanish. There are two types of posts on the website: default posts and a custom post type 'tutoriels' that uses a rewritten slug 'base-de-connaissance'.

The post-type is declared with the following parameter:

 'rewrite' => array( 'slug' => esc_html__( 'base-de-connaissance', 'probanceknowledgebase' ), 'with_front' => false, ), 

This slug is translated with WPML.

Symptoms:
On the English and Spanish versions of the website, visitors get a 404 error every time they try to access a tutorials-typed post from the live search results and from the search page, even though the URLs are correct.
Once you get the error, you get 404 every time you try accessing the base-de-connaissance and its related taxonomy archive pages.
Everything works as expected in the main version (French).
The problem doesn't occur when the live search module is deactivated, but it can be reproduced with several modules that do the same thing.
The problem doesn't occur if I remove the rewriting of the tutoriels custom post-type's slug.

Questions:
How can I fix the 404 error on translated custom post types when using the live search module?
Is there a way to maintain the rewritten slug without causing 404 errors on translated versions?

February 5, 2025 at 1:42 pm #16671314

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hi,

Have you tried this plugin: Ajax Search Pro which is fully compatible with WPML? The free version is also compatible.

If it does not work:
Can you please access the fresh WP installation and install and set up the bare minimum to reproduce the problem?
hidden link

Thanks!

Best Regards,
Otto

February 6, 2025 at 10:40 am #16674794

emmanuelD-13

Thank you for your response Otto.

I just tried using Ajax Search Pro : the same issue occurs.

Weirdly enough, I can't seem to reproduce the problem in the Sandbox environment : I added the custom post-type, set up the rewritten slug translation with WPML and activated Relevanssi Live Ajax Search, and the search feature is working properly on the translated versions of the website.

I did notice something surprising : while testing things out, I changed the rewritten slug of the custom post-type to "retete, and then changed in back to "base-de-connaissance" in function.php, but in WPML > Settings > Post Types Translation, the slug is still registered as "retete", even after deleting WPML's cache.

Should I try importing the entire theme of my website ?

capture.PNG
February 6, 2025 at 3:45 pm #16676363

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello, and thanks for testing this.

First, regarding the weird thing:
- I went to WPML > String translation.
- Searched for the string "retete" and deleted it
- Then I went to WPML > Theme and Plugins localization and rescanned the theme again
- After that, the slug of the post type is back to Baise de reconnaissance
- I translated it and everything kept working as expected.

So, it may be a compatibility issue with other components of your site.

About uploading your custom theme. You can do it and I am happy to take a look. But bear in mind that custom code is outside the scope of our support. I'll do my best to point you in the right direction but I may need to stop at some point 🙁

That said, before testing your theme in the sandbox environment I suggest you discard other compatibility issues on your end.

To do so:
❌ Please make a full website backup before proceeding ❌
Check if this issue appears in your test site when:
-Only WPML, its add-ons and Ajax Search Pro plugins are activated, as it will tell us if there is an interaction issue with another plugin

If you don't see the issue in the above scenario, activate one plugin at a time until you see the problem reappearing.

Let me know how this goes, please.

Best Regards,
Otto

The topic ‘[Closed] Error 404 when accessing a translated custom-typed post with a live search plugin’ is closed to new replies.