Trying to implement wp-bootstrap-navwalker.php
into my made from scratch template for wordpress.
The File for the class-wp-bootstrap-navwalker.php
is located in the root directory of my theme.
functions.php
function register_navwalker()
{
require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';<br>
}
add_action( 'after_setup_theme', 'register_navwalker' );
register_nav_menus( array( 'primary' => __( 'Primary Menu', 'primary' ), ) );
cover.php
With the code below within the <nav> and </nav>
tags
<?php
wp_nav_menu( array(
'theme_location' => 'top-menu',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
?>
When I save changes and reload my website, I get get the wp-bootstrap-navwalker page from github.
I've checked the source of the page and see this at the footer:
Fatal error: Uncaught Error: Class 'WP_Bootstrap_Navwalker' not found in C:\laragon\www\VzyulTech\wp-content\themes\Version2\index.php:17
Stack trace:
#0 C:\laragon\www\VzyulTech\wp-includes\template-loader.php(106): include()
#1 C:\laragon\www\VzyulTech\wp-blog-header.php(19): require_once('C:\laragon\www\...')
#2 C:\laragon\www\VzyulTech\index.php(17): require('C:\laragon\www\...')
#3 {main}
thrown in C:\laragon\www\VzyulTech\wp-content\themes\Version2\index.php on line 17
When I check line 17 it is the 'walker' => new WP_Bootstrap_Navwalker(),
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
any help is much appreciated.