This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Hook für Redirects in WPML >> Wordpress
#1
Hallo,
bin Anfänger in PHP, verstehe schon ein wenig vom Codieren in PHP, aber halt noch nicht so ganz.
Möchte beim Plugin WPML ( Wordpress ) einen Hook einhängen, der sich automatisch an der Browsersprache orientiert. Also es sind insgesamt 3 Sprachen, dt ist voreingestellt als Hauptsprache. Wenn jetzt jemand eine Browsersprache in italienisch vorweist soll eben auf /it/ umgeleitet werden, bei englisch entsprechend. Die Hauptdomain bleibt deutsch. Hier mal der Hook, der von WPML angeboten wird. Die Frage wer kann mir helfen bzw. Tipps geben, den Hook auszuprogrammieren. Es geht hier darum, die $params nach meinen oben erwünschten Vorhaben richtig zu codieren - auch z.B. für englisch die Browsersprache en_us ... zu berücksichtigen. Danke schon mal im Vorfeld für Eure Mühe.

function example_callback( $params ) {
global $post;
// Redirect the French language to the home page if the current page ID is 123
if ( $post->ID === 123 ) {
$params['pageLanguage'] = 'en';
$params['languageUrls'] = [ 'fr' => 'http://example.com/fr/' ];
}
return $params;
}
add_filter( 'wpml_browser_redirect_language_params', 'example_callback' );
Zitieren


Nachrichten in diesem Thema
PHP Hook für Redirects in WPML >> Wordpress - von alhai007 - 15.11.2022, 12:11

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste