【发布时间】:2015-02-18 04:39:55
【问题描述】:
我已经通过 bootstrap 最新版本制作了 wordpress 主题,但导航栏无法正常工作。我尝试了许多不同的方式来玩 wp_nav_menu(); 代码和 ul , li ,但没有任何效果!
这是我的header.php 代码:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<title><?php bloginfo( 'title' ); ?></title>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="dc:creator" content="http://www.myvivaid.com/" />
<meta name="geo.region" content="IR" />
<meta name="googlebot" content="index,follow" />
<meta name="robots" content="noodp,noydir" />
<meta name="robots" content="index, follow" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Raleway:400">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" />
<div class="col-12">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<?php wp_nav_menu(); ?>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>
<h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo( $show ); ?></a></h1>
<!--end menu-->
<?php wp_enqueue_script("jquery"); ?>
<?php wp_head(); ?>
</head>
<body>
这是我的footer.php:
<div class="col-md-12" id="footer">
<div class="col-lg-3">
<div class="spacer-1">
<a href="index.html"><img src="<?php bloginfo('template_directory'); ?>/img/myviva_footer.png" alt="مای ویوا آی دی"></a>
</div>
</div>
<div class="col-lg-5">
<div class="indent-top2">
<p><span class="glyphicon glyphicon-copyright-mark" aria-hidden="true"></span> <a href="http://www.myvivaid.com/">طراحی قالب بصورت اختصاصی</a> توسط MyVivaId.com صورت گرفته و هرگونه کپی برداری از این طرح با نارضایتی <a href="http://webmaker.ga/">طراح</a> همراه می باشد.</p>
<p><span class="glyphicon glyphicon-heart" aria-hidden="true"></span> <a href="http://webmaker.ga/">سفارش طراحی قالب</a><p>
</div>
</div>
<div class="col-lg-4">
<ul class="list-services">
<li><a href="https://www.facebook.com/pages/Myvivaid/1593182370893821"><i class="fa fa-facebook-square fa-2x"></i></a></li>
<li><a href="https://twitter.com/myvivaid"><i class="fa fa-twitter-square fa-2x"></i></a></li>
<li><a href="https://plus.google.com/113198960466603112632"><i class="fa fa-google-plus-square fa-2x"></i></a></li>
<li><a href="http://myvivaid.com/feed/"><i class="fa fa-rss-square fa-2x"></i></a></li>
</ul>
<span class="footer-text">© 2015 <a class="link color-2" href="#">تمام حقوق محفوظ</a></span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="<?php echo esc_url( get_template_directory_uri() . '/js/bootstrap.min.js' ); ?>"></script>
<?php wp_footer(); ?>
</div>
<a href="#top" id="smoothup" title="Back to top"></a>
</body>
</html>
【问题讨论】:
-
确保您已经从后端添加了菜单项,并且还提到了菜单项的主题位置。参考wp_nav_menu()
-
我做了,但之前显示的一样,没有任何变化!
-
您在哪个菜单位置添加了菜单?你在 wp_nav_menu 函数中写过相同的名字吗?
-
这是在functions.php //menu// function register_my_menus() { register_nav_menus( array( 'top-menu' => __( 'منو بالا' ) ) ); }
标签: php wordpress twitter-bootstrap navbar nav