[Support request] Logo url translation

Home Forums Support [Support request] Logo url translation

Home Forums Support Logo url translation

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1680991
    Ketil

    Hello,
    How can I make the logo follow the translation, I get the root url from all languages without the “/en” addition for english etc.

    #1681015
    Ying
    Staff
    Customer Support

    Hi Ketil,

    Give this php snippet a try:

    add_filter( 'generate_logo_href', function() {
        $currentlang = get_bloginfo('language');
        if($currentlang=="en-US"){
            return "your-custom-url";
        }
    } );

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

    #1681039
    Ketil

    Hi. Will the snippet code work with a relative link, and will I have to edit it when I add more languages to the site?

    #1681049
    Ying
    Staff
    Customer Support

    As long as the page’s language is en-US, it will work.

    If you add more language, you’ll need to edit the snippet a bit.

    #1698648
    Ketil

    Hi. Some problem has occured to the translation code for logo, it seems for norwegian translation the logo links to page itself instead of to the root. Works in English.

    #1699686
    Elvin
    Staff
    Customer Support

    Hi there,

    Let’s modify Ying’s code a bit.

    The issue here is: The filter doesn’t return href value for anything else.

    That said, We should make one.

    add_filter( 'generate_logo_href', function() {
        $currentlang = get_bloginfo('language');
        if($currentlang=="en-US"){
            return "your-custom-url";
        } else {
            return home_url( '/' );
        }
    } );

    The else statement is the default state. The other if() statements are for your specific languages.

    A wise man once said:
    "Have you cleared your cache?"

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