我正在尝试将WordPress与引导模板class一起使用navbar-fixed-top
与冲突body_class();
是否有解决此问题的方法?
编辑1:
其他详细信息,
我看不到导航,这是主要问题。我想用<?php body_class(); ?>
修复此问题,但没有结果。
以下是导航代码:
<body id="page-top" <?php body_class(); ?>>
<nav id="mainNav" class="navbar navbar-default navbar-fixed-top affix">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top">Start Bootstrap</a>
</div>
<!-- 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 navbar-right">
<li>
<a href="#about">About</a>
</li>
<li>
<a href="#services">Services</a>
</li>
<li>
<a href="#portfolio">Portfolio</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<!-- a lot more code and -->
</body>
以下是渲染后页面中的body标记:
<body id="page-top" class="home blog logged-in admin-bar no-customize-support">
SO网友:Amoy N
为什么不使用navwalker创建引导菜单?尝试https://github.com/wp-bootstrap/wp-bootstrap-navwalker
您可以将固定顶部添加到菜单中
<nav class="navbar navbar-default navbar-fixed-top" temscope="itemscope" itemtype="http://schema.org/SiteNavigationElement" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar">
<ul class="nav navbar-nav">
<?php
wp_nav_menu( array(
\'menu\' => \'primary\',
\'theme_location\' => \'primary\',
\'depth\' => 2,
\'container\' => \'div\',
\'container_class\' => \'\',
\'container_id\' => \'collapse navbar-collapse\',
\'menu_class\' => \'nav navbar-nav\',
\'fallback_cb\' => \'wp_bootstrap_navwalker::fallback\',
\'walker\' => new wp_bootstrap_navwalker())
);
?>
</ul>
</div>
</div>
SO网友:Nathan Johnson
管理栏和导航栏重叠的原因是它们都固定在屏幕顶部。有两种方法可以解决此问题:
使用PHP,您可以删除管理栏。将以下内容添加到函数中。php或独立插件:
add_filter( \'show_admin_bar\', \'__return_false\' );
或使用CSS。将此添加到主题样式中。css或在自定义程序中:
.admin-bar .navbar { top: 32px; }