Jump to content

Recommended Posts

Hi all

 

Our website has 9 languages and I have a ribbon banner graphic placed on top of the header. I would like to know if it is possible to have 9 images (one for each) for the languages but to show the image corresponding to the country chosen, for example /en or /fr etc.

 

Using wordpress 3.6

The image looks for a page /satisfaction-guarantee/ and will go to the relevant country on click, eg, /en/satisfaction-guarantee/ etc. 

Would love to know how to do the same kind of thing for the actual ribbon banner also.

 

Thanks shmideo

 

The code that shows the banner is below:

 

<div id="inner_wraper">
    <div class="menu_wrap">
        <div id="header">    
              <?php  wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'my_nav','sort_column'=>'menu_order' ) );
              ?>
        </div>
    </div>
    <div class="clear"></div>
    <div class="slider_logo_wrap">

        <div id="top_banner">
            <a href="<?php bloginfo('url')?>/satisfaction-guarantee/"><img src="<?php echo get_option('banner_image'); ?>" alt=" "/></a>

        </div>

Link to comment
https://forums.phpfreaks.com/topic/283155-show-image-depending-on-country/
Share on other sites

I experimented a few ways with exploding the current url but it can get messy dealing with pages and subdomains.

 

Hopefully this way can work for you and modify to all your languages and where you store the banner images at.

<?php
$pageURL = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

if(preg_match("~/fr/~",$pageURL)){
$page_language = "fr";
}elseif(preg_match("~/it/~",$pageURL)){
$page_language = "it";
}else{
$page_language ="en";
}

$banner_location = "http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png";
?>

<div id="inner_wraper">
    <div class="menu_wrap">
        <div id="header">    
              <?php  wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'my_nav','sort_column'=>'menu_order' ) );
              ?>
        </div>
    </div>
    <div class="clear"></div>
    <div class="slider_logo_wrap">

        <div id="top_banner">
            <a href="<?php bloginfo('url')?>/<?php echo $page_language."/";?>satisfaction-guarantee/"><img src="<?php echo $banner_location; ?>" alt=" "/></a>

        </div>
Edited by QuickOldCar

Yes I cannot find where it actually gets the image name from. I know where the image is on the server but that's about all.

Have checked Wordpress and nowhere I can see where the image is (corner_banner.png).

Have done a content search for the image name on the server and no sign of it.

 

Thanks

shmideo

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.