Jump to content

Archived

This topic is now archived and is closed to further replies.

dbarrera

WPML Conditional Statement in Global Scope

Recommended Posts

dbarrera

Website URL: barreralawfirm.com/beta/
Framework Version: Just updated today. 
WordPress Version: Most recent
Plugins in Use: WPML,  Formcraft, Jetpack, SEO Ultimate
Server/Host: Siteground
Screenshots:
Details: Below

 

I am currently developing a website with both English and Spanish text. Dependent on the language selected via the fixed nav, the site will pull different code/text. Is there a way to run php in a textbox within the header or global scope? There is one section that needs to conform to that. I have checked the string translations and it isn't showing up to be manageable through that. I have also tried a <?php if(ICL_LANGUAGE_CODE=='en'): ?> statement to get it to switch manually but the code won't run.

 

Is there a better way to get this content to translate when on a different language?

 

Any help would be greatly appreciated.

 

 

Share this post


Link to post
Share on other sites
dbarrera

Eventually got it to work with the following:

 

Created the shortcode in functions.php:

 

function webtreats_lang_test( $atts, $content = null ) {
    extract(shortcode_atts(array('lang'      => '',), $atts));
    $lang_active = ICL_LANGUAGE_CODE;   
    if($lang == $lang_active){
        return $content;
    }
}
 
Shortcode: [wpml_translate lang=en] Content [/wpml_translate]

Share this post


Link to post
Share on other sites
James B

Glad you got it working, thank you for updating the thread with the solution.


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites
ketri

 

Eventually got it to work with the following:

 

Created the shortcode in functions.php:

 

function webtreats_lang_test( $atts, $content = null ) {
    extract(shortcode_atts(array('lang'      => '',), $atts));
    $lang_active = ICL_LANGUAGE_CODE;   
    if($lang == $lang_active){
        return $content;
    }
}
 
Shortcode: [wpml_translate lang=en] Content [/wpml_translate]

 

 

 

Could you clarify this solution? This seems awesome but I cannot get it working. 

Is that all the code that should go to functions.php ? Where is the "wpml_translate " -part in the function?

Share this post


Link to post
Share on other sites
Danny

I haven't ever used the WPML plugin, but a quick search for that shortcode returned the following post - http://wpml.org/forums/topic/wpml-shortcode/

 

If you're still struggling, I recommend you post on their support forum for assistance.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • Anthony King
      By Anthony King+
      Hello,
      I am wanting to know what the status of the Pagelines Platform.
      I have noticed that there has been absolutely no updates on Platform 5 for over 8 months.
      Please tell me you haven't gone off on another tangent and going to build the next great solution
      and then leave all of us to have to completely rebuild our sites like we did for
      Pagelines, then DMS, then Pagelines Platform.
      I like what you build, but what you need to do is build one product and then make it better, rather than 
      abandoning it and building something else.
      You haven't done anything for so long that even WordPress is providing a warning.
      "Warning: This plugin has not been tested with your current version of WordPress."
      So what is the Status. I mean if I am going to pay a monthly fee for a product, I don't want to pay for one
      that is no longer being supported. You have a great product, I'm not bashing it, I'm just wondering what 
      your next move is because I have business decisions to make for myself, and whether of not this is something
      I should stick with.

      Please be kind enough to respond.

      Thank You,
      Anthony
    • tuciudadenred
      By tuciudadenred+
      Hi everyone, what happens is that the web page metrosalarmas.com has a google tags which I have not attacked where I can look to remove those tags and be able to locate the correct ones.
    • JP
      By JP+
      Hello,
      We are working on a 2 languages site (https://liguecardioliga.be) with wpml, and lately the call of a category in the loops section (and all the sections requiring a category to select posts) doesn't work in the translated language. It worked well until recently so I wonder if it's because of a recent update (wordpress, wpml, pagelines, a plugin?). Anyone has the same problem? a solution?
      TIA
    • oseehys
      By oseehys+
      Hello There,
      So i want to use platform 5 and DMS sections on a single page, i am using a child theme with pinspro as my main theme and i activated platform 5, the only problem am having so far is the fixed option, my navbars are not aligning to their default size, and it will be great if platform 5 header and footer section will function, has anyone used this option, how can i make the best use of platform 5 and DMS on a site
      Cheers
    • thirdstonemedia
      By thirdstonemedia+
      I've been fighting with a resolution issue ? Want to use Flick Slider, the site looks great on my monitor but client says she can't see bottom of homes. I believe she's on an old PC using outdated browser/s ... but, she's important to me and I'd like to make this work, on her system. Without asking her adjust her own set-up. 
      I put the Flick Slider inside a container, here ::
      http://becauze.xyz/home-five
      Set the Height of Flick Slider to 50 Base ... I don't know how this works exactly ... there is a Base then a Min ... but, haven't adjusted the Min ::
      http://becauze.xyz/home-four/
      Tried using Splash Up, which presents the same issue (she can only see top of home) and she wants several images to rotate on Home page, so not sure this would work anyway ::
      http://becauze.xyz/
      I have tried going into Layout and making the width narrower, and that does make the site narrower, but the homes still don't display in full, on her system. Help ?

      Here are her screen grabs, both desktop and iPad  (dumped the chalkboard background).

      FInally, she said these look great ::
      http://www.sinclairaia.com/
      http://www.kristihanson.com/
      What am I doing wrong ?? Is there a better way to accomplish making the site look great on any resolution at any size ?
      Joanne
      (Longtime Pagelines-lover.)


×