[Resolved] Elements depending on language (with WPML)

Home Forums Support [Resolved] Elements depending on language (with WPML)

Home Forums Support Elements depending on language (with WPML)

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #1291421
    Christoph

    We are using Generate Press and WPML, for a website in spanish and english. We are using for each language a different domain:
    Spanish: http://www.concepto3s.com
    English: http://www.3hconcept.com

    (1) Different Logo each language:
    I tried with ELEMENTS a Hook for all the website, before logo and this code

    <?php if ( ICL_LANGUAGE_CODE == 'en' ) { ?> 
        <img src="http://www.concepto3s.com/wp-content/uploads/2020/05/3hconcept-web.jpg" alt="" />
     
    <?php } else { ?>   
        <img src="http://www.concepto3s.com/wp-content/uploads/2020/05/concepto3s-web.jpg" alt="" />
    
    <?php } ?>

    to show a different logo depending on the language (as I found in another Support Topic). But now, there is no logo shown, not in spanish, not in english.

    (2) Would it be possible also to use a different FAVICON depending on the language? and
    (3) Also using a different “Copyright Content” depending on the language?

    #1292365
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Is it the same WordPress installation with two different domains?

    What kind of logo setup are you using by default? Have you simply added it through Customize > Site Identity?

    #1292447
    Christoph

    Hi, hello,

    yes, the same WordPress installation with 2 domains. The WPML Tutorial:
    https://wpml.org/tutorials/2016/04/use-wpml-different-domains-per-language/

    Yes, by default the spanish logo by Customize > Site Identity.

    #1292891
    Tom
    Lead Developer
    Lead Developer

    Give this function a shot:

    add_filter( 'generate_logo', function( $logo ) {
        if ( ICL_LANGUAGE_CODE == 'en' ) {
            return 'URL TO ENGLISH LOGO';
        }
    
        return $logo;
    } );

    Let me know ๐Ÿ™‚

    #1293276
    Christoph

    I am not sure, where and how to add this function.

    #1293455
    David
    Staff
    Customer Support

    Hi there,

    this article explains how to add that PHP snippet:

    https://docs.generatepress.com/article/adding-php/

    #1293635
    Christoph

    Ok, now it shows this error:

    Warning: Use of undefined constant CL_LANGUAGE_CODE – assumed ‘CL_LANGUAGE_CODE’ (this will throw an Error in a future version of PHP) in /var/www/web1780/html/wp-content/plugins/code-snippets/php/snippet-ops.php(446) : eval()’d code on line 2

    #1294481
    Tom
    Lead Developer
    Lead Developer
    #1294932
    Christoph
    #1295680
    Tom
    Lead Developer
    Lead Developer

    I actually made a change to it – can you try the updated code?

    #1295799
    Christoph

    Yes, this updated code works. Thanks!

    #1296012
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #1839940
    Serhii

    Hello, Team!

    I use this code:

    add_filter( 'generate_logo', function( $logo ) {
        if ( ICL_LANGUAGE_CODE == 'en' ) {
            return 'URL TO ENGLISH LOGO';
        }
    
        return $logo;
    } );

    It works well for me. But i also have on my site logo on sticky menu – inside div with class=”sticky-navigation-logo”.
    How to change logo on sticky menu?
    I use GP Premium and WPML. My site will have three logos: russian, english and ukrainian.

    #1840482
    Elvin
    Staff
    Customer Support

    Hi Serhii,

    I’m not sure I fully understand what you mean.

    To clarify:

    Does the sticky menu logo have to be different w/ the static menu logo? Meaning it changes logo when you scroll down?

    #1841329
    Serhii

    No, the sticky menu logo must be the same as the static menu logo.
    Both types of logo should change depending on the language of the site.

    The above code only works for the static menu logo.
    I need some code that will change also sticky menu logo when switching site display language.

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