如果URL包含特定字符串,如何更改genesis Wordpress上的徽标和菜单


How to change logo and menu on genesis Wordpress if URL contains a certain string?

我在Wordpress上使用Genesis框架,当URL包含特定字符串时,我想更改徽标和主菜单。例如,如果URL为http://example.com/testing我想要一个徽标和菜单,例如.com,另一个当URL中有"测试"时。

我已经尝试过更改徽标:

    function new_headerimage(){
    if(basename($_SERVER['REQUEST_URI']) == 'testing') {
        echo '<div class="testing-header"><a href="http://example.com/testing"><img src="http://example.com/wp-content/uploads/2016/04/logotest.jpeg" alt="logo image" /></a></div>';
   } else {
       echo '<div class="original-header"><a href="http://example.com/"><img src="http://example.com/wp-content/uploads/2016/04/logotest2.jpeg" alt="logo" /></a></div>';
}}
add_action('genesis_header', 'new_headerimage');

但它只会在example.com/testing而不是example.com/testing/test2上显示新徽标。如果URL中包含"测试"一词,而不仅仅是测试是基本名称,那么如何让它只进行搜索?

按以下方式尝试

 function new_headerimage(){
        if(strpos($_SERVER['REQUEST_URI'],'testing') !== false ) {
             echo '<div class="original-header"><a href="http://example.com/"><img src="http://example.com/wp-content/uploads/2016/04/logotest2.jpeg" alt="logo" /></a></div>';
       } else {
           echo '<div class="testing-header"><a href="http://example.com/testing"><img src="http://example.com/wp-content/uploads/2016/04/logotest.jpeg" alt="logo image" /></a></div>';
    }
}
add_action('genesis_header', 'new_headerimage');