Via the WPML Job Board I came across a very interesting challenge.
Instead of having the usual flag / language name in the languages switcher, this client wanted to change that anchor text into the localized titles of the content.
And for the home and blog pages the output needed to be fixed.
I always like a good puzzle and fortunately was awarded the job to put this highly customized languages switcher together for the client.
The category archive pages as well as the product category archive pages were the biggest challenge as I discovered a WPML bug where for these pages the wpml_object_id
filter does not properly work. Instead of outputting the translated category titles the output showed the correct link, but the title in the current language.
As bugs usually take a while to be fixed, I managed to solve that issue in a very creative way where I have taken the url (which of course also contains the category name) and strip everything out so only the slug remains. Then with a second str_replace()
I have removed the hyphens (-
) from the slug and what is left is basically the category name.
And after the client thanked me for my work, I finally also realised the purpose of the job:
everything is working in the way I had in mind
your code is a great addition to my SEO and no-one else has it
thanks again