Skip Navigation

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 26 replies, has 2 voices.

Last updated by aarynB 1 year, 10 months ago.

Assisted by: Mateus Getulio.

Author Posts
March 15, 2023 at 5:55 pm #13254473

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Thanks for your efforts.

Sorry about this back and forth, but it seems that the contractors page does not exist in the staging version? Moreover, even on the live website I wasn't able to find it.

I had to access the database, to access a previous version and restore its content: hidden link. It is strange that even on this new page the US language does not work.

By chance, do you have a backup prior to these changes? If yes, could you please restore this backup?

I'm out of ideas here, since we're unable to do more complex tests in a copy version (for example, deactivate the plugins and update WPML). Please let me know about the backup and as soon as possible I'll escalate the question to our second tier team.

Thanks,
Mateus.

March 15, 2023 at 6:01 pm #13254503

aarynB

I do have a backup, but it's a couple weeks old. I will re-install it.

March 15, 2023 at 6:11 pm #13254511

aarynB

I've contacted our IT Department to replace the last backup from their master. I will advise once done.

March 16, 2023 at 12:22 pm #13259193

aarynB

Our last update has been re-installed, and the staging site is available for you again. Please confirm receipt of this message.

March 16, 2023 at 12:37 pm #13259305

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thanks a lot for restoring the websites.

We're back in debugging the issue. As soon as possible we'll provide you with updates.

Thanks for your patience in the meantime.

Regards,
Mateus.

March 16, 2023 at 7:15 pm #13263933

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello again,

I have double-checked the problem, but so far I haven't been able to find a fix. I asked my colleagues to take a look to see if there's anything I'm missing.

I'll come back here as soon as one of them answers me (which shouldn't take long). Thank you in advance for your patience!

Regards,
Mateus.

March 17, 2023 at 2:12 pm #13270255

aarynB

Mateus, thank you for the update. Please keep me posted.

March 17, 2023 at 9:18 pm #13272869

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

I have escalated this ticket to our 2nd tier of support where our 2nd tier specialists will take a deeper look at this issue and will try to find a solution.

I will get back to you as soon as I get an answer from them.

Best regards,
Mateus

March 20, 2023 at 1:14 pm #13284539

aarynB

Mateus, thank you again for the update. Hoping the solution can be found through Tier 2.

March 20, 2023 at 9:13 pm #13288215

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thanks for your patience.

Upon further inspection, we were able to spot several issues in the codes of your custom theme. For example, in the file: /wp-content/themes/lifebreath/controllers/Language.php you have this custom logic: https://pastebin.com/5zFQgsAg

This is hooked onto:

add_action( 'posts_where', array( $this, 'posts_where' ) );

And this is what makes the post return 404 error in the frontend. Basically, the code "switch the language" by replacing a query with a regular expression to the default language. So, if we have a clause "WHERE":

AND (wp_posts.ID = '321739') AND wp_posts.post_type = 'page' AND ( ( ( wpml_translations.language_code = 'us' OR 0 ) AND wp_posts.post_type  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','product','product_variation','team-member','testimonial','resource','career' )  ) OR wp_posts.post_type  NOT  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','product','product_variation','team-member','testimonial','resource','career' )  )</cde>

The logic replaces it to:

[php] AND (wp_posts.ID = '321739') AND wp_posts.post_type = 'page' AND ( ( ( wpml_translations.language_code = 'en' OR 0 ) AND wp_posts.post_type  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','product','product_variation','team-member','testimonial','resource','career' )  ) OR wp_posts.post_type  NOT  IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','product','product_variation','team-member','testimonial','resource','career' )  )

If our post with ID 321739 (new translation in our sandbox) is with language "us", it alters the query so that we search for language "en" and this returns NOTHING. Here is where the problem lies.

As a workaround, you can go to the file: /wp-content/themes/lifebreath/controllers/Language.php, and comment-out the hook:

add_action( 'posts_where', array( $this, 'posts_where' ) );

And it should work fine.

However, please note: the solution provided is to be used just as an informational one. Remember that custom coding is out of the scope of our support so we can't create, debug or modify code for you and it's your responsibility to maintain it. We hope the one we used as an example could point you in the right direction. Please check our support policy: https://wpml.org/purchase/support-policy/

Thanks for your understanding.

Regards,
Mateus.

March 21, 2023 at 12:21 pm #13293281

aarynB

Mateus, I'm not sure I understand the workaround solution you've outlined here. Have you made the edit, or do I need to have it done? Please advise.

AB

March 21, 2023 at 7:44 pm #13297765

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thanks for your reply.

We have tested the workaround in our copy versions, and it works. Now you need to apply it to your website, could you please do that and tell us how it goes?

Just make sure to have a website backup before doing so.

Thank you, please let me know.

March 24, 2023 at 12:06 pm #13323075

aarynB

I have arranged for a developer to work on this next week. Please do not close this just yet. I will be in touch once they have had a chance to work on things.