Archived topic
Can I avoid duplicating display rules with WPML?
5 replies · Started by Gabriel on February 21, 2022
I have created a few layout and block elements and added display rules in my default language (Swedish). Having to add the same display rules for translations as well will be a bit of a maintenance pain. Is there some clever method that would allow me to create an element, set a display rule for a page in the default language and have that element automatically be applied to translations of that page?
maybe not the tipp you are asking for, but forget about WPML - this behemoth acts so weird and slow in many ways.
it is super easy to migrate to polytrans and so many headaches are gone.
I developed a deep hate against WPML, because it does so many bloatet unnecessary things and tends to break at the weirdest corners of your WP installation. moving from wpml to polylang was like going from divi to generatepress.
I don't know whether WPML is broken in this case or if this is just how it works.
Hi Gabriel,
You may have to maintain the display rule through PHP snippets if its a pain to go back and forth w/ Block editor's UI.
Here's the filter to use for it - https://docs.generatepress.com/article/generate_element_display/
And yeah that's just how WPML or any translation plugin works. Translation pages or posts are replica but they're technically separate posts. That's why the language toggle has to be there. (in case a specific condition is needed on a per language basis).
Ok thanks for clarifying. Then it seems that the behavior is expected with the current implementation.
About doing this programmatically, is the element id portable between installations? Say I put my element display logic in functions.php of my child theme, can I import my elements to another site without having to change the $element_id conditions in functions.php?
About doing this programmatically, is the element id portable between installations? Say I put my element display logic in functions.php of my child theme, can I import my elements to another site without having to change the $element_id conditions in functions.php?
If its a direct database clone then the element IDs will stay intact.
If it's an importation of the GP_element post type then it will be changed as its current GUID may already be taken by an existing post on the destination site where the elements are to be imported on.