Reply To: WPML translation and search


Ernest Marcinko


Your code looks correct to me.

As far as I know WPML does create separate posts with different IDs for translations, so the post ID should be enough as the argument for the cart to know which language to use. The icl_translations table only hods the relationship information of the translated posts.

I think (I'm not sure) this might be an issue with how the cart handles the URL. I'm guessing it automatically gets the actual site translations, no matter if the post ID represents a different locale.

I'm not sure if it's possible to force it somehow to display items in original locales, as WPML kicks in and it automatically converts everything to the current language. It might be converted automatically when it's displayed, not when added to cart.

After digging a bit, I have found this and this. Based on those, I've made a modification to your filter:

But I highly doubt it will make any difference if the item language is converted upon displaying. In that case I'm not sure if there is anything we can change within the search code. Let me know if you find anything!

Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)