This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by brunoD-31 11 months, 3 weeks ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
October 22, 2018 at 9:41 am #2837470

brunoD-31

I am trying to:

Show specific content according to the current viewing language.

Link to a page where the issue can be seen:
This is a staging environment, I can't show you a specific page, but I can show you my code;
https://pastebin.com/ybpnqUeL

I added this code to my functions.php file of my child theme.

But for some reason only the else statement is loaded and it can't check if ($lang == "en") {

When I reload the page and check the var_dum() I load at the start I get the following flash:
hidden link

I expected to see:
Text according to language.

Instead, I got:
Always the message in the else statement.

October 23, 2018 at 3:18 am #2840651

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Thank you for contacting WPML support. I'd be happy to assist you further on this issue.

I just tested the constant on my test server and I can see it's working without any issues. The code implementation you have is also correct, so it seems like an issue only in your site.

As a test could you please use the constant inside the function once and see if that helps?

Further, could you please perform the below steps and share me the results?

Debugging
1. Please follow the debugging information provided here: http://wpml.org/documentation/support/debugging-wpml/
2. Repeat the action of creating the problem.
3. Copy and paste the contents of debug.log (log file inside the /wp-content/ directory) here for me to see.

Look forward to your reply.

Thanks

October 25, 2018 at 2:06 pm #2850087

brunoD-31

My issue is resolved now. Thank you!