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 1 year, 7 months ago.

Assigned support staff: Shekhar Bhandari.

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


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;

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

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?

1. Please follow the debugging information provided here:
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.


October 25, 2018 at 2:06 pm #2850087


My issue is resolved now. Thank you!