我使用WordPress 3中的本机菜单生成器构建了一个导航菜单。这是我用来渲染它的代码:
<?php wp_nav_menu( array(\'menu\' => \'Main Navigation\',\'menu_id\'=> \'headernav\',\'menu_class\'=>\'navigate\')); ?>
它完全按照我在每一页上所期望的方式呈现except 404.php。这就是它在其他地方的渲染方式:<div class="menu-main-navigation-container"><ul id="headernav" class="navigate">
这就是它在404上的渲染方式。php:<div class="navigate"><ul>
和404。php它列出了我网站上的每一个页面,而不是我在菜单中内置的页面。有人知道为什么会这样吗?非常感谢您的帮助。
编辑
这是我函数中的代码。php文件:
function mytheme_setup() {
register_nav_menus( array(
\'main-navigation\' => \'Main Navigation\',
\'subnav-navigation\' => \'Sub menu nav\',
\'how-eli-works-nav\' => \'How Eli Works\'
) );
}
add_action( \'after_setup_theme\', \'mytheme_setup\' );
我也按照你的建议做了,然后回到菜单面板并指定了主题位置。同样的结果:事情在以前的地方运行,404。php仍处于崩溃状态。这是从我的标题调用菜单的代码。php文件:
<?php wp_nav_menu( array(\'theme_location\' => \'main-navigation\', \'menu\' => \'Main Navigation\',\'menu_id\'=> \'headernav\',\'menu_class\'=>\'navigate\')); ?>
这是我404的代码。php文件:<?php
get_header(); ?>
<div id="pagecontent" class="narrowcolumn" role="main">
<article id="post-0" class="post error404 not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( \'Oops, we couldn’t find what you requested.\', \'twentyeleven\' ); ?></h1>
</header>
<div class="entry-content">
<p><?php _e( \'It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.\', \'twentyeleven\' ); ?></p>
<?php get_search_form(); ?>
<?php the_widget( \'WP_Widget_Recent_Posts\', array( \'number\' => 10 ), array( \'widget_id\' => \'404\' ) ); ?>
<div class="widget">
<h2 class="widgettitle"><?php _e( \'Most Used Categories\', \'twentyeleven\' ); ?></h2>
<ul>
<?php wp_list_categories( array( \'orderby\' => \'count\', \'order\' => \'DESC\', \'show_count\' => 1, \'title_li\' => \'\', \'number\' => 10 ) ); ?>
</ul>
</div>
</div>
<?php get_footer(); ?>