当前位置: 动力学知识库 > 问答 > 编程问答 >

wordpress - If else - how to switch between two php files depending on the url

问题描述:

So, I would like to switch between 2 php files depending on the url. So far my code looks like this...

 <?php $url = $_SERVER["REQUEST_URI"];

if (strpos($url, "/ru/")) {

<?php wp_nav_menu(array('theme_location' => 'Tours-en')); ?>

}else {

<?php wp_nav_menu(array('theme_location' => 'Tours-ru')); ?>

}

?>

I don't know what should be before <?php wp_nav_menu(array('theme_location' => 'Tours-en')); ?> like use <? php wp_nav_menu etc.. I hope you see what is my problem. I don't know the name of the "command" which should be before <?php.

To clarify, the two php files between which I would like to switch contain menus.

Any help would be appreciated.

网友答案:

What about this:

<?php 
    $url = $_SERVER["REQUEST_URI"];
    wp_nav_menu(array(
              'theme_location' => (strpos($url, "/ru/"))?'Tours-en':'Tours-ru'
                      ));
?> 
分享给朋友:
您可能感兴趣的文章:
随机阅读: