WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to organize some things in my custom theme, and so I'm using require to load in some custom classes I've created that implement native WordPress classes. When I code the class right into my theme's functions.php file, everything is hunky-dory... but move the class into a THEMEDIR/utilities/extendWalker.extension.php I get an error that the dependent Interface (the WP_NAV_WALKER from /wp-includes/nav-menu-template.php) can't be found... even though it does indeed exist in that location.

I can only surmise that I need to be loading externally defined classes on one of the action hooks during theme initialization, but which one? I've tried to search the codex, but searching codex or google for something like this will get you a thousand results you don't want. I need to make sure my theme is built properly, so things like nav menus work properly.. and I'm afraid to use the plugin hooks.

What's the best hook to use for theme utility classes? (stuff you might look to do via your functions.php file)

I'm currently getting it to work using:

function loadMyClass(){
    require_once THEMEDIR . '/utilities/myclass.php'

but don't want problems down the road with conflicts cause by scripts from plugins installed by the users or site admins.

share|improve this question
Do I get it right, you basically just took a part of your functions.php and put it into another file/directory that is included in your functions.php? – fischi Jan 31 '14 at 11:24
yes. I had a class defined in functions.php that extended wp core classes, and they worked fine until I moved them out of the functions file. It loads my class, but can't find the class I'm extending. – Brian Vanderbusch Jan 31 '14 at 16:19
Can you get me some access to your code? Hard to guess this way. – fischi Jan 31 '14 at 17:24
Have you got the right link? Does not work for me. – fischi Jan 31 '14 at 17:33
let us continue this discussion in chat – fischi Jan 31 '14 at 17:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.