fiskhandlarn/bootstrap-5-wordpress-navbar-walker
Composer 安装命令:
composer require fiskhandlarn/bootstrap-5-wordpress-navbar-walker
包简介
Bootstrap 5 WordPress Navbar Walker
README 文档
README
Installation
Require this package, with Composer, in the root directory of your project.
$ composer require fiskhandlarn/bootstrap-5-wordpress-navbar-walker
Usage
- Register a new menu by adding the follow code into the functions.php file of your theme:
register_nav_menu('main-menu', 'Main menu');
- Add the following html code in your header.php file or wherever you want to place your menu:
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<?php
wp_nav_menu([
'theme_location' => 'navigation',
'container' => false,
'menu_class' => '',
'fallback_cb' => '__return_false',
'items_wrap' => '<ul id="%1$s" class="navbar-nav me-auto mb-2 mb-lg-0 %2$s">%3$s</ul>',
'depth' => 2,
'walker' => new Fiskhandlarn\Bootstrap5WordpressNavbarWalker(),
]);
?>
</div>
</div>
</nav>
Add support for dropdown menu (responsive) alignment
- From Appearance -> Menus page of WordPress, check the CSS Classes checkbox under Screen Options;
- Add a Custom Link with "#" in the URL field (this would be the parent of your dropdown);
- On the CSS Classes field add any of the following alignment classes: 'dropdown-menu-start', 'dropdown-menu-end', 'dropdown-menu-sm-start', 'dropdown-menu-sm-end', 'dropdown-menu-md-start', 'dropdown-menu-md-end', 'dropdown-menu-lg-start', 'dropdown-menu-lg-end', 'dropdown-menu-xl-start', 'dropdown-menu-xl-end', 'dropdown-menu-xxl-start', 'dropdown-menu-xxl-end';
- If any of the mentioned above class is detected, then they will automatically copied into the ul.dropdown-menu element following the Bootstrap 5 structure;
- Any other class that is not related to the dropdown menu alignment will stay where it is.
License
fiskhandlarn/bootstrap-5-wordpress-navbar-walker 适用场景与选型建议
fiskhandlarn/bootstrap-5-wordpress-navbar-walker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.89k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 05 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fiskhandlarn/bootstrap-5-wordpress-navbar-walker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fiskhandlarn/bootstrap-5-wordpress-navbar-walker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-27