php - 将菜单添加到我的后导航?

标签 php html css wordpress

我希望在此字段中添加一个菜单“主页”、“联系我们”等 <div class="post-nav">http://boasish.com . enter image description here

我正在使用 Wordpress。黑色区域是我想要自定义菜单的地方。我的模板没有为我提供在那里添加小部件的选项,因此我想自己添加一个。页面上的其他一切都很好我只想在我指定的地方添加一个自定义菜单

这是有问题的代码。

<footer class="site-footer" role="contentinfo" itemscope="itemscope" itemtype="http://schema.org/WPFooter">
 <div class="wrap">
    <div class="post-nav">
    </div>
 </div>
</footer>

最佳答案

注册您的 custom menu通过将其添加到位于模板目录中的 functions.php

function my_footer_menu() {
  register_nav_menu('footer-menu',__( 'Footer Menu' ));
}
add_action( 'init', 'my_footer_menu' );

并将此添加到您的 footer.php 文件

<footer class="site-footer" role="contentinfo" itemscope="itemscope" itemtype="http://schema.org/WPFooter">
  <nav class="nav-primary">
       <div class="wrap">
          <div class="post-nav">
            <?php wp_nav_menu( array( 'theme_location' => 'footer-menu', 'container_class' => 'menu' ) ); ?>
          </div>
       </div>
  </nav>
</footer>

wp-admin 中,从 menu manager 添加您的菜单项.

我正在使用 .nav-primary 因为它是主题标题菜单类,因此您的页脚样式相似

关于php - 将菜单添加到我的后导航?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25733431/

相关文章:

php - 如何在 php 上从 GET 变量回显 javascript 编码的 url

php - jquery 中的对象使用 json 响应

html - 为什么不溢出 :hidden working in IE6?

html - 为什么看不到这个小部件?WordPress

javascript - 如何为 HTML 中表格的 <th> 元素提供工具提示

html - 在文本旁边对齐 <p> 内联

php - 如何从 PHP 使用 bash 脚本?

php - 使用准备好的语句进行多次插入

html - iOS 12 Safari iframe + 位置 : fixed + translate3d bug

asp.net - 如何使用 CSS 指定的 DOCTYPE 修复 100% 高度表格中的表格行高?