Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress From Bootstrap to WordPress Add Bootstrap Components to WordPress Theme Dropdown Bootstrap Menus and the Walker Class

alida strydom
PLUS
alida strydom
Courses Plus Student 1,712 Points

"Bootstrap Shortcodes" plugin, and bootstrap.min.js...

Okay, I've just come to grips with being completely bald after pulling out all my hair during the frustration caused by trying to implement dropdown menu items via Edward McIntyre's "wp-bootstrap-navwalker" method for my Bootstrap Wordpress theme, and thought of a question that would benefit myself and anyone else struggling:

In Zak's Bootstrap-to-Wordpress course, he instructs us to include bootstrap.min.js AND install the "Bootstrap shortcodes" plugin...

As it turns out, the wp-bootstrap-navwalker approach was not working because of a plugin conflict caused by the Bootstrap shortcodes plugin. In addition to the bootstrap.js that i was including via functions.php, the plugin was including another copy of bootstrap.js, so the page was loading 2 instances of bootstrap.js.

Upon disabling the plugin OR removing the code code from my functions.php, wp-bootstrap-navwalker worked.

So, how are we supposed to deal with this issue? Suppose I want to keep the Bootstrap shortcodes plugin....do i remove the code from functions.php?...Will the bootstrap.js included by the plugin serve all the purposes that would otherwise have been served by including bootstrap.js (or bootstrap.min.js) in functions.php?

1 Answer

Tim Knight
Tim Knight
28,863 Points

Hi Alida,

There is actually a setting in the plugin. If you go into Wordpress Settings you'll see "BS Shortcodes". In there the first two settings on the page will let you load the CSS and JS files for Bootstrap. Since you're already loading them, just uncheck those boxes, save, and everything should work just fine with Bootstrap and the nav walker.

alida strydom
alida strydom
Courses Plus Student 1,712 Points

Many thanks Tim!

As simple as it is, I would never have thought of checking Wordpress Settings for this.

Okay, so just to clarify, if I leave all options inside of BS Shortcodes checked, I don't actually need to register/enqueue anything Bootstrap-related manually in functions.php?

In fact, wouldn't it be better to get what I need from the plugin?...that way, I would always be using the latest versions of bootstrap's css and js?

Tim Knight
Tim Knight
28,863 Points

Personally Alida, I much prefer registering Bootstrap myself in the functions.php because than I know the version I'm using and I don't get any unexpected errors with a change in classes (if that ever happens). I don't want plugins interfering with any of the aspects that control the general UI of my site incase I need to disable a plugin for any reason.

But yes you're correct that if you wanted to use this you wouldn't have to enqueue them within functions.php, it's just not my preferred way to address it.