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

    • ideascurator
      By ideascurator+
      Hello Pagelines,   I no longer use pagelines services. I have deactivated the automatic annual payment. But it already charged to my credit card. Since I cancelled my contract before the end, Can I request to refund?
    • 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
×