最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dropdown - Bootstrap drop down Navigation Menu in WordPress

programmeradmin3浏览0评论

I am trying to build a Wordpress theme with boostrap.almost every part is complete but the nav menu is giving me some trouble for days. I would like the dropdown to work like boostraps dropdown, but I do not know how to do this.

So I need:

To add the class "dropdown", if a menu-item has child-items. dropdown-toggle sticky-top also i need necessary bootstrap web srcs or download links and local src like this: get_template_directory_uri() . '/js/scriptname.js' Hope someone can help!

when i try , the page looks like:

I am trying to build a Wordpress theme with boostrap.almost every part is complete but the nav menu is giving me some trouble for days. I would like the dropdown to work like boostraps dropdown, but I do not know how to do this.

So I need:

To add the class "dropdown", if a menu-item has child-items. dropdown-toggle sticky-top also i need necessary bootstrap web srcs or download links and local src like this: get_template_directory_uri() . '/js/scriptname.js' Hope someone can help!

when i try https://github/wp-bootstrap/wp-bootstrap-navwalker , the page looks like:

Share Improve this question edited Jul 2, 2019 at 15:32 Murat Deniz asked Jul 2, 2019 at 13:17 Murat DenizMurat Deniz 77 bronze badges 3
  • There are plugins that will do this for you. If you want to DIY, you'll need a custom Nav Walker to add your required CSS classes, and download Bootstrap and enqueue all of its resources in a child theme. – WebElaine Commented Jul 2, 2019 at 13:20
  • will these plugins cause slow the website? if i can do it without plugin, it will be better for me so can you tell me the how to? i found some php files and codes but they didnt work fully. – Murat Deniz Commented Jul 2, 2019 at 13:27
  • A plugin won't slow down your website any more than putting the same code into a child theme will, and the added benefit of a plugin is someone else maintains the code and keeps it all up to date for you. But like I said, you can use a Nav Walker (like the one in Nathan's answer) and also enqueue the required CSS and JS files. – WebElaine Commented Jul 2, 2019 at 13:57
Add a comment  | 

1 Answer 1

Reset to default 1

You will want to extend the Walker_Nav_Menu class. This allows you to "walk" through the various states of a navigation menu. One of the first google searches I did for the term Walker_Nav_Menu led me to this Github repo with a class already built. wp-bootstrap-navwalker.

发布评论

评论列表(0)

  1. 暂无评论