0

I have a multi-lingual site. It only allows for one logo. I need a condition that will show the English logo version for the site, unless you are on the french site to show the french version. I found some code on this site but it's not working for me.

Any suggestions?

Basically, show the french logo if the url shows FR at the end. if not, show the english.

<?php

   if (strpos($_SERVER["REQUEST_URI"], "www.radarhh.com/stage/fr/") !== 0): ?>
   <a href="/" rel="home" id="logo_fr" title="radar Chasseurs De Talents">
   <img src="../RadarHeadhuntersFR.png"> 
   </a>


<? else: ?>

    <a href="<?php echo get_site_url(); ?>" class="logo" title="radar Headhunters"><img src="<?php the_theme_option("logo"); ?>" alt=""  width="<?php the_theme_option("header_logo_standart_width"); ?>" height="<?php the_theme_option("header_logo_standart_height"); ?>" class="logo_def"><img src="<?php the_theme_option("logo_retina"); ?>" alt="" width="<?php the_theme_option("header_logo_standart_width"); ?>" height="<?php the_theme_option("header_logo_standart_height"); ?>" class="logo_retina"></a>


<? endif; ?>
2
  • Are you using a specific plugin for the language switch? Oct 16, 2014 at 2:05
  • i am using wpml to manage the language switch
    – amaunzie
    Oct 16, 2014 at 16:58

1 Answer 1

1
if (strpos($_SERVER["REQUEST_URI"], "www.radarhh.com/stage/fr/") !== 0):

The $_SERVER["REQUEST_URI"] typically doesn't contain the domain name. And you should be checking if it is zero, since strpos returns the position of the string, or false if it's not in the string.

Try this instead:

if ( strpos( $_SERVER['REQUEST_URI'], '/stage/fr/' ) === 0 ) :

Also, you have this image:

<img src="../RadarHeadhuntersFR.png"> 

That should be a fully qualified URL, not starting with a ".." because that .. is relative to the URL, which might be different than the URL you're expecting.

Note: There are cases where $_SERVER["REQUEST_URI"] can contain the full URL, however in such a case, you would want to check against the actual full URL, with the http and everything. Not against just the partial URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.