Archived topic
Elements location assignments do not appear to work well with WPML
8 replies · Started by Jonathon on March 28, 2022
I'm building a local site and using some of your element hooks. I am also making the site bilingual using the WPML plugin. I have found that while I can translate an element into secondary languages the mechanics to control where they display is not acknowledging which language it is currently processing.
For example I created a hook that replaces the sidebar for a CPT. It works fine in the native language of English, but when I build the same element in Spanish the Spanish name for the CPT is not in the Locations list only the English. Thus the element doesn't trigger when visiting the content in Spanish.
Does that make sense?
It seems to me that the code that is generating the list of available Locations, Exclusions etc, doesn't take alternate languages into account.
Since this is a local site I'm not sure how to give you access, but if there are files or settings I can tell you about please let me know.
Hi Jonathon,
I'm not sure about WPML, but with Polylang (another translation plugin) , you can choose language for the element itself, once the language is chosen, the element only shows on pages which is using the same language.
Can you check if there's such a setting in element?
Here's an example with Polylang:
https://www.screencast.com/t/TnLGHF2b
Yes, I am making these changes while in the alternate language. The GeneratePress element components seem to ignore that transition. I'm pretty sure this is repeatable with an empty WordPress site, GeneratePress GP Premium and WPML only installed.
Steps:
1. Create a CPT with Toolset.
2. Create a translation of the CPT
3. Update the slugs so the url will show the changed url in both languages.
4. Create an Element using GeneratePress. Set it to use the location of the created CPT and show for all of the CPT.
5. Translate the element into second language and try to set the location for the translated CPT, but only English options are shown.
Jonathon
Just to be sure that you've chosen Spanish as the language for the element?
And assigned it to the CPT?
You are fast. I just updated my response with the steps I took. I also am filing a ticket with WPML, but I think this is on your side.
Yes, I am creating an element while in the Spanish "Side" of the admin area. However the Display Rules drop downs only include the english options and not the translated options which show up in other plugins.
Jonathon
5. Translate the element into second language and try to set the location for the translated CPT, but only English options are shown.
If you choose the same location as the English element, does the Spanish element show up on Spanish pages?
I don't think the location dropdown list will show the Spanish locations anyways.
No. The element does not show. I believe because it is being given the Spanish version of the content it doesn't think it needs to trigger.
The list shows CPTs that where generated in English. I don't see why it wouldn't show a CPT created in Spanish unless it isn't able to see them which in my opinion it should if it is compatible with WPML.
Jonathon
Okay. Nevermind. I clearly need to sleep more.
The Hook name was empty on the Spanish version of the Element. I'm sure I set it at one point, but who knows.
Sorry for bothering you all. Thank you for your time.
Jonathon
You are welcome :)