我正在尝试将语言选项添加到我的网站。我已经编写了我的主题,我需要用三种不同的语言显示web。我得到了一些小标志,并成功地用所选语言传递了一个php变量。使用该变量,我在标题中为wp\\u nav\\u菜单分配了一个if。php。它实际上是有效的。当我更改语言时,会出现正确语言的正确菜单。问题是,当我点击菜单项,所选页面打开时,菜单就消失了。消失。有人能帮我吗,普拉斯?这是我使用的代码。
在标题中。php
if ($language == \'en\') {
wp_nav_menu(array(
\'theme_location\' => \'eng\',
\'container_class\' => \'main-nav\',
\'container\' => \'nav\'
));
} else if ($language == \'de\') {
wp_nav_menu(array(
\'theme_location\' => \'ger\',
\'container_class\' => \'main-nav\',
\'container\' => \'nav\'
));
} else {
wp_nav_menu(array(
\'theme_location\' => \'esp\',
\'container_class\' => \'main-nav\',
\'container\' => \'nav\'
));
}
在函数中。php
add_theme_support (\'menus\');
//Create Nav Menu
if (function_exists (\'register_nav_menus\')) {
register_nav_menus (array(
\'esp\' => \'Spanish menu\',
\'eng\' => \'English menu\',
\'ger\' => \'Deutsch menu\'
));
}
以及标题中标志链接的html。php
<li><a href="http://localhost/wordpress/inicio?language=es" ><img src="http://localhost/wordpress/wp-content/themes/wordpressthemeAPI2/img/espflag.PNG" width="18" height="12" onmouseover="this.src=\'http://localhost/wordpress/wp-content/themes/wordpressthemeAPI2/img/espH.PNG\'" onmouseout="this.src=\'http://localhost/wordpress/wp-content/themes/wordpressthemeAPI2/img/espflag.PNG\'"></a></li>