我開始主題發展與引導。導航菜單出現問題。WordPress的導航菜單不工作
在的header.php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => 'nav',
'container_class' => 'navbar-collapse collapse',
'menu_class' => 'nav navbar-nav navbar-right'
));
在的functions.php
register_nav_menus(array(
'primary' => esc_html__('Primary Menu', 'test1-wp-theme'),
));
有什麼不對嗎?我是新手,開發wordpress主題首次
這裏充滿的header.php
<?php
/**
* The header for our theme.
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package T1_WP
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/assets/css/main.css">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e('Skip to content', 'test1-wp-theme'); ?></a>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">ABC Blog</a>
</div>
<?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => 'nav',
'container_class' => 'navbar-collapse collapse',
'menu_class' => 'nav navbar-nav navbar-right'
));
?>
</div>
</nav>
<div id="content" class="site-content">
UPDATE
我已刪除了所有的數組項,現在它的工作。但我不明白什麼是確切的問題?
<?php
wp_nav_menu(array(
));
?>
你的代碼看起來還好,你有沒有分配給主菜單位置菜單? –
只需添加<( '主', 'theme_location'=> '初級', 'menu_class'=> 'NAV導航欄-NAV導航欄右')的PHP wp_nav_menu陣列( '菜單'=)?>; ?> 貌似容器 –
感謝的問題,它的工作現在:) – NeosFox