[Resolved] Bug Elements and Display Rules and WPML /WPML global locations bug ongoing

Home Forums Support [Resolved] Bug Elements and Display Rules and WPML /WPML global locations bug ongoing

Home Forums Support Bug Elements and Display Rules and WPML /WPML global locations bug ongoing

  • This topic has 13 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #662583
    Martin U

    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

    #662746
    Tom
    Lead Developer
    Lead Developer

    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.

    #662942
    Martin U

    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

    #663483
    Tom
    Lead Developer
    Lead Developer

    Thank you! We’ll take a closer look at WPML and will try to make it perfectly compatible.

    Really appreciate your feedback 🙂

    #664125
    Martin U

    You are very welcome. Please let me, if I can help.

    #666723
    Tom
    Lead Developer
    Lead Developer

    WPML provided this function to another member: https://gist.github.com/srdjan-jcc/00ee8d15afb3c6c1497af5ff92d32a8e

    Perhaps it will help?

    #666905
    Martin U

    Thank you, I will give it a try

    #666980
    Tom
    Lead Developer
    Lead Developer

    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

    #671680
    Martin U

    Thanks Tom, I have tested the hook version and it did well with display rules like “Site” or “Frontpage”

    #671952
    Tom
    Lead Developer
    Lead Developer

    Awesome 🙂

    #863672
    Martin U

    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.

    #864177
    Tom
    Lead Developer
    Lead Developer

    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/

    #865319
    Martin U

    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.

    #865500
    Tom
    Lead Developer
    Lead Developer

    Awesome! Thanks for testing!

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.