MWDelaney / sage-bootstrap4-navwalker

MIT License
73 stars 34 forks source link

Class App\wp_bootstrap4_navwalker not found using either method #12

Closed ardiewen closed 4 years ago

ardiewen commented 5 years ago

Hi there,

I'm following the updated instructions and running into the exact same issue as described in #1.

My local environment configuration is Trellis + Bedrock + Sage per the roots.io documentation. The staging site is a relatively new and clean setup.

Steps to replicate:

  1. Ran composer require "mwdelaney/sage-bootstrap4-navwalker" in my theme folder
  2. Copy/pasted the code in the "Without Controller" section into my header.blade.php:
<div class="collapse navbar-collapse justify-content-end" id="navbarToggler">
   @if (has_nav_menu('primary_navigation'))
      {!! wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'navbar-nav', 'walker' => new \App\wp_bootstrap4_navwalker()]) !!}
   @endif
</div>
  1. Received the following error: Screen Shot 2019-03-16 at 1 02 19 AM

Tried the following:

  1. Also tried the Controller method, see my App.php:
<?php

namespace App\Controllers;
use Sober\Controller\Controller;

class App extends Controller
{

...

/**
 * Primary Nav Menu arguments
 * @return array
 */
public function primarymenu() {
  $args = array(
    'theme_location'    => 'primary_navigation',
    'menu_class'        => 'navbar-nav',
    'walker'            => new \App\wp_bootstrap4_navwalker(),
  );
  return $args;
}
}
  1. Then added the following to my header.blade.php instead:
@if (has_nav_menu('primary_navigation'))
  {!! wp_nav_menu($primarymenu) !!}
@endif
  1. Receive this error instead: Screen Shot 2019-03-16 at 1 14 03 AM

Any insights on how to better troubleshoot this would be greatly appreciated. Thanks!