这是我用来调用wp\\u nav\\u菜单的代码
<?php
wp_nav_menu(
array(
\'container_class\' => \'menu-header\',
\'theme_location\' => \'\',
\'menu_id\' => 6,
\'depth\' => 4
)
);
?>
该菜单在主页和单个帖子页面上显示得非常完美,如下所示:http://www.enkitec.com/但当我访问分类页面时,例如。http://www.enkitec.com/education/菜单项发生变化,似乎有些菜单项没有出现。
note: 我在仪表板中只有1个菜单,它被设置为默认菜单
strange thing is: 上面的代码包含在标题中。php,所以它在所有页面上都是相同的,但在类别页面上的结果仍然不同。
任何帮助都将不胜感激
此外,我还包括我的主题页代码:
header.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="<?php bloginfo( \'charset\' ); ?>" />
<title><?php wp_title(\'-\', true, \'right\'); ?> <?php bloginfo(\'name\'); ?></title>
<meta name="description" content="<?php echo is_single() ? single_post_title(\'\', true):bloginfo(\'name\')." - ".bloginfo(\'description\'); ?>" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo(\'stylesheet_url\'); ?>" />
<link rel="stylesheet" href="<?php bloginfo(\'template_url\'); ?>/font_kit/stylesheet.css" type="text/css" charset="utf-8" />
<link rel="shortcut icon" href="<?php bloginfo(\'template_url\'); ?>/favicon.ico" />
<link rel="pingback" href="<?php bloginfo(\'pingback_url\'); ?>" />
<script type="text/javascript" src="<?php bloginfo(\'template_url\'); ?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo(\'template_url\'); ?>/js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="<?php bloginfo(\'template_url\'); ?>/js/jquery-textFill-0.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(\'#slider\')
.after(\'<div id="controls">\')
.cycle({
fx: \'fade\',
speed: 2500,
timeout: 5000,
pager: \'#controls\',
slideExpr: \'a\'
});
});
</script>
<?php if (is_singular() && get_option(\'thread_comments\')) wp_enqueue_script(\'comment-reply\'); ?>
<?php wp_head(); ?>
</head>
<body>
<div id="custom_wrapper">
<div class="header">
<div class="left">
<div class="logo"></div>
</div><!--left-->
<div class="right">
<div class="image"></div>
</div><!--right-->
</div><!--header-->
<div class="menu">
<div class="left"></div>
<div class="inner" id="menu">
<?php
wp_nav_menu(
array(
\'container_class\' => \'menu-header\',
\'theme_location\' => \'\',
\'menu_id\' => 6,
\'depth\' => 4
)
);
?>
</div><!--inner-->
<div class="right"></div>
</div><!--menu-->
<div class="clear_10px"></div>
<?php $single_cat_title = single_cat_title(); ?>
<?php $p_title = trim(wp_title(NULL, FALSE)); ?>
<?php $cat = get_the_category(); $c_title = trim($cat[0]->name); ?>
category.php <div id="content" class="categories">
<div class="left border_right">
<?php if (have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php // the_content(); ?>
<?php the_excerpt(); ?>
<div class="clear_10px border_bottom"></div>
<div class="meta">
<?php the_time(\'F jS, Y\') ?>,
By <?php the_author_posts_link(); ?>.
Filed Under: <?php the_category(\', \'); ?>
</div><!--meta-->
<div class="clear"> </div>
<?php endwhile; ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link(__(\'« Older posts\', \'\')); ?></div>
<div class="nav-next"><?php previous_posts_link(__(\'Newer posts »\', \'\')); ?></div>
</div><!-- #nav-below -->
<div class="clear"> </div>
<?php endif; ?>
<?php else : ?>
<h2>Nothing Found</h2>
<p>Sorry, but you are looking for something that isn\'t here.</p>
<p><a href="<?php echo get_option(\'home\'); ?>">Return to home page</a></p>
<div class="clear_10px border_bottom"></div>
<?php endif; ?>
<?php if (is_home()) : ?>
<div class="check_us_out"></div>
<?php endif; ?>
<div class="clear"></div>
</div><!--left-->
<div class="right">
<?php get_sidebar(); ?>
</div><!--right-->
</div><!--content-->
<?php get_footer(); ?>
一<div id="content" class="categories"> <div class="left border_right"> <?php if (have_posts()) : ?> <?php while(have_posts()) : the_post(); ?> <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1> <?php // the_content(); ?> <?php the_excerpt(); ?> <div class="clear_10px border_bottom"></div> <div class="meta"> <?php the_time(\'F jS, Y\') ?>, By <?php the_author_posts_link(); ?>. Filed Under: <?php the_category(\', \'); ?> </div><!--meta--> <div class="clear"> </div> <?php endwhile; ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link(__(\'« Older posts\', \'\')); ?></div> <div class="nav-next"><?php previous_posts_link(__(\'Newer posts »\', \'\')); ?></div> </div><!-- #nav-below --> <div class="clear"> </div> <?php endif; ?> <?php else : ?> <h2>Nothing Found</h2> <p>Sorry, but you are looking for something that isn\'t here.</p> <p><a href="<?php echo get_option(\'home\'); ?>">Return to home page</a></p> <div class="clear_10px border_bottom"></div> <?php endif; ?> <?php if (is_home()) : ?> <div class="check_us_out"></div> <?php endif; ?> <div class="clear"></div> </div><!--left--> <div class="right"> <?php get_sidebar(); ?> </div><!--right--> </div><!--content--> <?php get_footer(); ?>
functions.php
<?php /* Register a Custom Post Type (Slide) */ add_action(\'init\', \'slide_init\'); function slide_init() { $labels = array( \'name\' => _x(\'Slides\', \'post type general name\'), \'singular_name\' => _x(\'Slide\', \'post type singular name\'), \'add_new\' => _x(\'Add New\', \'slide\'), \'add_new_item\' => __(\'Add New Slide\'), \'edit_item\' => __(\'Edit Slide\'), \'new_item\' => __(\'New Slide\'), \'view_item\' => __(\'View Slide\'), \'search_items\' => __(\'Search Slides\'), \'not_found\' => __(\'No slides found\'), \'not_found_in_trash\' => __(\'No slides found in Trash\'), \'parent_item_colon\' => \'\', \'menu_name\' => \'Slides\' ); $args = array( \'labels\' => $labels, \'public\' => true, \'publicly_queryable\' => true, \'show_ui\' => true, \'show_in_menu\' => true, \'query_var\' => true, \'rewrite\' => true, \'capability_type\' => \'post\', \'has_archive\' => true, \'hierarchical\' => false, \'menu_position\' => null, \'supports\' => array(\'title\', \'excerpt\', \'thumbnail\') ); register_post_type(\'slide\', $args); } /* Update Slide Messages */ add_filter(\'post_updated_messages\', \'slide_updated_messages\'); function slide_updated_messages($messages) { global $post, $post_ID; $messages[\'slide\'] = array( 0 => \'\', 1 => sprintf(__(\'Slide updated.\'), esc_url(get_permalink($post_ID))), 2 => __(\'Custom field updated.\'), 3 => __(\'Custom field deleted.\'), 4 => __(\'Slide updated.\'), 5 => isset($_GET[\'revision\']) ? sprintf(__(\'Slide restored to revision from %s\'), wp_post_revision_title((int) $_GET[\'revision\'], false)) : false, 6 => sprintf(__(\'Slide published.\'), esc_url(get_permalink($post_ID))), 7 => __(\'Slide saved.\'), 8 => sprintf(__(\'Slide submitted.\'), esc_url(add_query_arg(\'preview\', \'true\', get_permalink($post_ID)))), 9 => sprintf(__(\'Slide scheduled for: <strong>%1$s</strong>. \'), date_i18n(__(\'M j, Y @ G:i\'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__(\'Slide draft updated.\'), esc_url(add_query_arg(\'preview\', \'true\', get_permalink($post_ID)))), ); return $messages; } /* Update Slide Help */ add_action(\'contextual_help\', \'slide_help_text\', 10, 3); function slide_help_text($contextual_help, $screen_id, $screen) { if (\'slide\' == $screen->id) { $contextual_help = \'<p>\' . __(\'Things to remember when adding a slide:\') . \'</p>\' . \'<ul>\' . \'<li>\' . __(\'Give the slide a title. The title will be used as the slide\\\'s headline.\') . \'</li>\' . \'<li>\' . __(\'Attach a Featured Image to give the slide its background.\') . \'</li>\' . \'<li>\' . __(\'Enter text into the Visual or HTML area. The text will appear within each slide during transitions.\') . \'</li>\' . \'</ul>\'; } elseif (\'edit-slide\' == $screen->id) { $contextual_help = \'<p>\' . __(\'A list of all slides appears below. To edit a slide, click on the slide\\\'s title.\') . \'</p>\'; } return $contextual_help; } if (function_exists(\'add_theme_support\')) { add_theme_support(\'post-thumbnails\'); } function checkFeild($a) { if (trim($a)==""||$a==NULL||empty($a)) { return false; } else { return true; } } if (function_exists(\'register_sidebar\')) { register_sidebar(array( \'before_widget\' => \'<div class="block">\', \'after_widget\' => \'</div><!--block-->\', \'before_title\' => \'<h1>\', \'after_title\' => \'</h1>\', )); } function register_my_menus(){ register_nav_menus( array( \'header-menu\'=>__(\'Header Menu\') ) ); } add_action(\'init\', \'register_my_menus\'); function fix_missing_menu($query) { $query->set(\'post_type\', array(\'post\', \'nav_menu_item\')); } add_filter(\'pre_get_posts\', \'fix_missing_menu\'); ?>