Looking for someone with experience with multilingual sites and perhaps the Polylang plugin.
According to the documentation it is possible to use a static front page:
"You have to create one page per language. Set translations as usual and then go to the WordPress ‘Reading settings’ panel. Check ‘Front page displays a static page’ and choose one of the page you have just created (the language doesn’t matter). Do the same for posts page if you use posts."
I've done all this, created a 2nd template
for the german version, and I'm using this in the german version of the Page used for the front page. When I look at my Pages overview, I see both the original version and the german version are tagged by Wordpress as Front Page. However when I use the language switcher to switch to german, the site continues using the original
.
Any idea what I'm doing wrong here?
<hr>
EDIT
<hr>
New
code after creating
and
:
I wondered if I had to do an
condition, but I've no idea how to do that when curly brackets {} are not being used.
I got the above code from:
<blockquote>
Get a specific file
Although this kind of defeats the purpose of this function, it’s also
possible to load a specific template file with it. All you have to do
is use just one argument:
will include layout.php from template-parts subdirectory placed in the
root of your theme folder.
( <a href="https://developer.wordpress.org/reference/functions/get_template_part/" rel="nofollow noreferrer">https://developer.wordpress.org/reference/functions/get_template_part/</a> )
</blockquote>
As the new templates are not in any specific sub-folder I didn't include the 'template-parts' part of the directory.
<hr>
EDIT 2
<hr>
<hr>
EDIT 3
<hr>
According to the documentation it is possible to use a static front page:
"You have to create one page per language. Set translations as usual and then go to the WordPress ‘Reading settings’ panel. Check ‘Front page displays a static page’ and choose one of the page you have just created (the language doesn’t matter). Do the same for posts page if you use posts."
I've done all this, created a 2nd template
Code:
front-page-de.php
Code:
front-page.php
Any idea what I'm doing wrong here?
<hr>
EDIT
<hr>
New
Code:
front-page.php
Code:
nl.php
Code:
de.php
Code:
<?php
/**
* Template Name: Front Page Template
*/
$currentLanguage = get_bloginfo('language');
// Replace this condition with language code, ex : en-US
if ( $currentLanguage == "nl-NL" )
get_template_part('nl');
$currentLanguage = get_bloginfo('language');
// Replace this condition with language code, ex : en-US
if ( $currentLanguage == "de_DE" )
get_template_part('de');
?>
I wondered if I had to do an
Code:
else
I got the above code from:
<blockquote>
Get a specific file
Although this kind of defeats the purpose of this function, it’s also
possible to load a specific template file with it. All you have to do
is use just one argument:
Code:
<?php get_template_part('template-parts/layout'); ?>
will include layout.php from template-parts subdirectory placed in the
root of your theme folder.
( <a href="https://developer.wordpress.org/reference/functions/get_template_part/" rel="nofollow noreferrer">https://developer.wordpress.org/reference/functions/get_template_part/</a> )
</blockquote>
As the new templates are not in any specific sub-folder I didn't include the 'template-parts' part of the directory.
<hr>
EDIT 2
<hr>
Code:
<?php
/**
* Template Name: Front Page Template
*/
$currentLanguage = get_bloginfo('language');
if ( $currentLanguage == "nl-NL" ) {
get_template_part('nl');
}
else {
get_template_part('de');
}
?>
<hr>
EDIT 3
<hr>
Code:
<?php
/**
* Template Name: Front Page Template
*/
$currentLanguage = pll_current_language();
if ( $currentLanguage == "nl-NL" ) {
get_template_part('nl');
}
else {
get_template_part('de');
}
?>