【发布时间】:2014-02-16 20:52:15
【问题描述】:
我在首先创建我的网站时遇到了这个问题,我的 header.php 页面中有一个菜单。 然后我想把我的网站变成一个wordpress网站,所以我做了我必须做的事情,但问题是我仍然想不出一种方法来将header.php中的导航菜单转换成一个可以工作的菜单在 wordpress 上。
我已经尝试了 wordpress 教程以及一些论坛提供的所有解决方案,但我尝试的所有方法都会在我想要的菜单之上创建一个丑陋的菜单,甚至无法点击。
我能够创建一个菜单位置或任何其他位置,当我在仪表板中创建菜单时,我在所需菜单的顶部得到了这个创建的菜单。当我将鼠标悬停在我想要的菜单上时(在以下代码中:main_menu),甚至没有任何反应。
这是我的 header.php:
<?php
/**
* The Header template for our theme
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package WordPress
* @subpackage Twenty_Thirteen
* @since Twenty Thirteen 1.0
*/
?><!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]--><head>
<?php /* Get our main menu Navigation bar */ ?>
<?php get_template_part( 'navigation', 1 ); ?>
<?php /* Get our top menu Navigation bar */ ?>
<?php get_template_part( 'navigation', 2 ); ?>
<?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'container_class' => 'main_menu' ) ); ?>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width">
<title><?php wp_title( 'entendrelimage', true, 'right' ); ?></title>
<link rel="profile" href="http://www.entendrelimage.univ-paris1.fr/">
<link rel="pingback" href="<?php bloginfo( 'entendrelimage_url' ); ?>">
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header>
<div id="main_menu">
<nav>
<ul>
<li><a href="#page2">Décryptage</a></li>
<li><a href="#page3">Symboles</a></li>
</ul>
</nav>
<br/ class="annuleFloat">
<ul id="recherche">
<li><a href="www.google.com"><img id="glo" src="<? bloginfo('stylesheet_directory'); ?>/images/glosaire_off.png" alt=""/></a></li>
<li><img src="<? bloginfo('stylesheet_directory'); ?>/images/ligne_top_right.png"/></li>
<li><a href="#"><img id="rech" src="<? bloginfo('stylesheet_directory'); ?>/images/recherche_off.png" alt=""/></a></li>
</ul>
</div>
<div id="logo">
<a href="#page1"><img src="<? bloginfo('stylesheet_directory'); ?>/images/logo.png" alt=""/></a>
<br/ class="annuleFloat">
</div>
</header>
<!-- #masthead -->
<div id="container">
<div class="main">
这是我放在functions.php中的部分代码:
function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu' );
所以如果有人能告诉我这个问题,那就太好了!我拼命地卡在这个上
【问题讨论】: