• Is there a way to make polylang be able to customize the missions news child theme logo for our website depending on the language (one logo for french language, one for english language) ?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Thanks for using Mission News!

    You may want to get in touch with the Polylang developers about this, but it looks like they have a conditional function you could use: https://polylang.pro/doc/function-reference/

    You could use an if statement to check the language like this:

    if (pll_current_language('de') ) {
      echo 'German content';
    }

    Please note that I just typed this out here so it’s not tested – it’s just a reference based on their docs.

    Thread Starter le.mag.cinema

    (@lemagcinema)

    thanks for your reply. I made it another way, by subclassing the_get custom_logo method
    but I would have preferred if the function was avalaible directly from polylang without having to change the code.
    :

    function custom_polylang_multilang_logo( $value ) {
    	if ( function_exists( 'pll_current_language' ) ) {
    		$logos = array(
    			'fr' => wp_get_attachment_image('xxx', 'full'),
    			'en' => wp_get_attachment_image('xxx', 'full'),
    		);
    		$default_logo = $logos['fr'];
    		$current_lang = pll_current_language();
    		if ( isset( $logos[ $current_lang ] ) )
    			$value = $logos[ $current_lang ];
    		else
    			$value = $default_logo;
    	}
    	$html = sprintf( '%2$s',
                esc_url( home_url( '/' ) ),
                $value
            );
    	return $html;
    }
    add_filter( 'get_custom_logo', 'custom_polylang_multilang_logo' );
    Theme Author Ben Sibley

    (@bensibley)

    That looks like a nice solution. Thanks for posting your code here for anyone else who needs this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘polylang and the-custom-logo’ is closed to new replies.