tonik / theme

Tonik is a WordPress Starter Theme which aims to modernize, organize and enhance some aspects of WordPress theme development.
http://labs.tonik.pl/theme/
MIT License
1.33k stars 140 forks source link

Nav Walker #78

Closed gbarrow85 closed 5 years ago

gbarrow85 commented 6 years ago

What would be the best way to extend the WP Walker_Nav_Menu menu class? I'm trying to create a custom nav walker.

msacchetti commented 6 years ago

Under the Structure dir I make a file called navwalker.php with this code in it

class Navwalker extends \Walker_Nav_Menu {
//code here
}

then in config/app.php add this to the autoload array Structure/navwalker.php

gbarrow85 commented 6 years ago

Thanks I did the same, I was unsure of the best place to house the file. Maybe something for the doc's custom walkers are pretty common.

jedrzejchalubek commented 5 years ago

I would recommend putting your Walker classes at app/Structure/Walkers/nav-walker.php and import it in config/app.php file.

As folder structure is flexible this is a recommendation, but feel free to structure it how it feels right for your project.