Wordpress - 条件标签在header.php中的位置?

时间:2013-07-17 17:02:32

标签: php wordpress header conditional

我想将此条件标记(不包括我的“商店”页面中的导航菜单)放入我的header.php

<?php if ( !is_page( 'shop' ) ) { 
  wp_nav_menu( array( 
    'show_home' => 'Home', 
    'container' => 'false', 
    'theme_location' => 'main') 
    ); 
  }
  endif;
  ?>

也许代码错了,但是当我将它粘贴到header.php的开头时,整个网站崩溃了!

非常感谢任何建议!

1 个答案:

答案 0 :(得分:1)

请注意第一行中的:http://php.net/manual/en/control-structures.alternative-syntax.php

<?php
if ( !is_page( 'shop' ) ) :
    wp_nav_menu( array(
        'show_home' => 'Home',
        'container' => 'false',
        'theme_location' => 'main')
    );
endif;
?>

OR:

<?php
if ( !is_page( 'shop' ) ) {
    wp_nav_menu( array(
        'show_home' => 'Home',
        'container' => 'false',
        'theme_location' => 'main')
    );
}
?>