Custom menu not appearing
-
Hey y’all. I’ve run searches and read quite a bit on this, and honestly I can’t figure out what it is that I’m missing. I have the following code in my custom theme directory:
functions.php
$fn = new MyNamespace\MyClass(); add_action('init',array($fn,'registerMenus'));
MyClass.php
namespace MyNamespace; class MyClass{ public function registerMenus(){ \register_nav_menus(array( 'header-menu'=>__('Header Menu') )); } }
header.php
<nav id="header-navigation" role="navigation"> <?php if(has_nav_menu('header-menu')){ print("<p>Right here would be good, ya</p>"); wp_nav_menu(array('theme_location'=>'header-menu')); }else{ print("<p>No menu, no happy.</p>"); } ?> </nav>
I assigned 2 CPTs to the Header Menu (named ‘Corporate Menu’) in the Appearance > Menus page of my WP back-end. I get the ‘Right here would be good, ya’ message printed out exactly where I want it. However, I’ve got no menu.
Can anyone see what I’m dong wrong here? My code looks like the examples I’ve found online and I don’t recall reading anything about a menu system revamp in 4.0, and I’m stymied…
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Custom menu not appearing’ is closed to new replies.