Archived topic
Bug Elements and Display Rules and WPML /WPML global locations bug ongoing
13 replies · Started by Martin U on August 28, 2018
Hi Guys,
there is unfortunately a major bug in the display rules of elements when working with WPML
1.
If I assign "Front Page" to an element the English Version of the element gets displayed on the English and German version of the home page.
If I assign the translated German version to "Front Page" as well the English and the German version get displayed both in the English and in the German version.
This basically means Elements and as such GPP is not compatible with WPML. Please fix this or offer workaround.
2.
BTW assigning an element to the home page via page name does not work at all. I feel is another bug.
There either needs to be a "Front page" "Blog" per language version or GPP needs to be able to get the right language version.
3.
The old page headers btw still not work with WPML and global locations. that hasn't been fixed
Hi there,
1. We can try using a filter like this as a workaround:
add_filter( 'generate_header_element_display', function( $display, $element_id ) {
if ( is_front_page() ) {
// Target our German Header Element with the ID: 10
if ( 10 === $element_id ) {
if ( 'de_DE' === get_locale() ) {
return true;
} else {
return false;
}
}
// Target our English Header Element with the ID: 20
if ( 20 === $element_id ) {
if ( 'de_DE' !== get_locale() ) {
return true;
} else {
return false;
}
}
}
return $display;
}, 10, 2 );
So the above targets our front page and will display the Header with the ID 10 when German is set, and 20 when it's not set.
Note that I don't know if get_locale() is compatible with WPML. They might have a function you need to use instead of it.
2. This is a known issue we're looking into.
Thank you for the fast reply, Tom.
I managed to use a workaround with conditional WPML language short codes.
The solution is documented here, in case anybody else comes across the same problem.
https://generatepress.com/forums/topic/wpml-page-header-global-locations/
Another thing I noticed, which I feel is a bug in the "display rules"
If I'm selecting specific pages for an English language element to be displayed, I get offered both pages. The page in English and in German language.
The way it should work - in my understanding and compared to similar plugins:
English element --> only English pages in the display rules
German element --> only German pages in the display rules.
I sincerely hope that the display rules get fixed to work flawlessly with WPML. WPML is pretty much the industry standard for multilingual Wordpress sites.
If you need something tested, please let me know. We have a universal unlimited WPML license.
best Martin
Thank you! We'll take a closer look at WPML and will try to make it perfectly compatible.
Really appreciate your feedback :)
You are very welcome. Please let me, if I can help.
WPML provided this function to another member: https://gist.github.com/srdjan-jcc/00ee8d15afb3c6c1497af5ff92d32a8e
Perhaps it will help?
Thank you, I will give it a try
Just a note that the above will only work for the Hook element type.
To make it work with Headers, you'd replace this:
generate_hook_element_display
With this:
generate_header_element_display
Thanks Tom, I have tested the hook version and it did well with display rules like "Site" or "Frontpage"
Awesome :)
Just a note that the above will only work for the Hook element type.
To make it work with Headers, you’d replace this:
generate_hook_element_display
With this:
generate_header_element_display
If anybody reads this, just tested that today. This actually works.
GPP 1.8.0 has support for WPML now, so you don't need to use the filter method: https://generatepress.com/gp-premium-1-8/
great news, Tom!
even better news: it actually works. Tested a header element on the frontpage worked out of the box under 1.8.
Thank you so much.
Awesome! Thanks for testing!