You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you encounter errors with the above code use a check like this to return clean errors to help diagnose the problem.
46
45
47
46
```php
48
-
<?php
49
47
if ( ! file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {
50
48
// file does not exist... return an error.
51
49
return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
You will also need to declare a new menu in your `functions.php` file if one doesn't already exist.
@@ -66,18 +64,16 @@ register_nav_menus( array(
66
64
Add or update any `wp_nav_menu()` functions in your theme (often found in `header.php`) to use the new walker by adding a `'walker'` item to the wp_nav_menu args array.
67
65
68
66
```php
69
-
<?php
70
67
wp_nav_menu( array(
71
-
'theme_location' => 'primary',
72
-
'depth' => 2, // 1 = no dropdowns, 2 = with dropdowns.
68
+
'theme_location' => 'primary',
69
+
'depth' => 2, // 1 = no dropdowns, 2 = with dropdowns.
@@ -122,11 +118,10 @@ To display the menu you must associate your menu with your theme location. You c
122
118
There has been some interest in making this walker the default walker for all menus. That could result in some unexpected situations but it can be achieved by adding this function to your functions.php file.
@@ -162,9 +157,9 @@ To make an item appear with the icon only apply the bootstrap screen reader clas
162
157
163
158
To set a disabled link simply add `disabled` to the **CSS Classes** field in the Menu UI and the walker class will do the rest. _Note: In addition to adding the .disabled class this will change the link `href` to `#` as well so that it is not a followable link._
Headersand dividers can be added within dropdowns by adding a Custom Link and adding either `dropdown-header`or `dropdown-divider` into the **CSS Classes** input. _Note: This will remove the `href` on the item and change it to either a `<span>` for headers or a `<div>` for dividers._
162
+
Headers, dividers and text only items can be added within dropdowns by adding a Custom Link and adding either `dropdown-header`, `dropdown-divider`or `dropdown-item-text` into the **CSS Classes** input. _Note: This will remove the `href` on the item and change it to either a `<span>` for headers or a `<div>` for dividers._
0 commit comments