Skip to content

Instantly share code, notes, and snippets.

@ashwebstudio
Created April 20, 2020 21:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ashwebstudio/a6d47b88690c6bd7a9eb27b8968972bd to your computer and use it in GitHub Desktop.
Save ashwebstudio/a6d47b88690c6bd7a9eb27b8968972bd to your computer and use it in GitHub Desktop.
TranslatePress Set Language To Cookie
@morgangrip
Copy link

Exactly what i'm looking for. I need to display two different maps for two languages (sv_SE and second language en_GB). I have installed and activated your plugin and made the conditional settings in Beaver Themer but i can not get it to work. Dont know what i'm missing here?

@Ciao121
Copy link

Ciao121 commented Aug 12, 2023

I have a proble using this. I'm trying to use this code in a custom wordpress php page initiated like that:
define( 'WP_USE_THEMES', true );
require_once( $_SERVER[ 'DOCUMENT_ROOT' ] . '/wp-load.php' );
On those pages the value of $TRP_LANGUAGE is everytime "es_US"
Any idea?

@ashwebstudio
Copy link
Author

I have a proble using this. I'm trying to use this code in a custom wordpress php page initiated like that: define( 'WP_USE_THEMES', true ); require_once( $_SERVER[ 'DOCUMENT_ROOT' ] . '/wp-load.php' ); On those pages the value of $TRP_LANGUAGE is everytime "es_US" Any idea?

Seems like something to ask the TranslatePress people about, but since that is a non-standard way of doing things in WordPress I don't think they will have much of an answer for you. Might have to dig into the code to see when $TRP_LANGUAGE actually gets set by TranslatePress and find another way to make it work OR do something within normal WordPress.

@Ciao121
Copy link

Ciao121 commented Aug 25, 2023

Thank you.

@Ciao121
Copy link

Ciao121 commented Aug 25, 2023

I think I understood where the problem is.
If I am on a page like: https://mysite.com/it/page, $TRP_LANGUAGE is it_IT.
But if I go to the home page WITHOUT THE SLUG (https://mysite.com) $TRP_LANGUAGE revert to en_US. And the same happens with custom pages.
This means that by default TranslatePress does not remember user last visited language. The sell an add on to do that (didn't knew).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment