如何在wordpress中设置菜单

时间:2016-03-21 14:52:04

标签: wordpress menu wordpress-theming

/*My header menu code*/

$args = array(
    'theme-location' => 'primary'
);
wp_nav_menu($args);

/*My footer menu code*/
$args = array(
    'theme-location' => 'footer'
);
wp_nav_menu($args); ?>

我的functions.php文件

register_nav_menus(
array(
    'primary' => __('Main Primary Menu'),
    'footer'=> __('Footer Menu'),
    )
);

当我为页眉和页脚选择不同的菜单时,它优先考虑页眉菜单和页眉中的设置页脚菜单但是当我删除页脚菜单然后它设置我为页眉选择的菜单,有什么问题是什么?

1 个答案:

答案 0 :(得分:0)

使用以下代码

/*My header menu code*/

$header_args = array(
  'theme-location' => 'primary'
);
wp_nav_menu($header_args);

/*My footer menu code*/
$footer_args = array(
  'theme-location' => 'footer'
);
wp_nav_menu($footer_args);