I've split my functions.php into multiple files using require_once, which works perfectly. However when I add admin functionality (extra panels) in one of the included files, it doesn't work? It's making me put the code in functions.php which I don't want to do.

This is the top of my functions.php

ini_set('display_errors', True);

// Includes
require_once('includes/admin.php'); // Admin stuff
  • You'll have to check if you're in admin: if ( is_admin() ). If you're asking the oposite, then your're denying access.
    – kaiser
    Commented Apr 19, 2012 at 13:46
  • There is no condition for the included files, I've just tried adding if(is_admin()) but no luck. Commented Apr 19, 2012 at 13:52
  • In short: If you're questioning if ( is_admin() ) then the following stuff only triggers if you're on an admin page. So you maybe have something wrapped into such a statement (or the ! is_admin() opposite) and therefore your files aren't loading.
    – kaiser
    Commented Apr 19, 2012 at 13:56
  • There are no conditions for the included file, I have require_once('includes/admin.php'); at the top of my functions.php :) Commented Apr 19, 2012 at 14:03
  • Turn on all your DEBUG stuff including all php error stuff.
    – kaiser
    Commented Apr 19, 2012 at 14:04

1 Answer 1


The problem here is that you're not including yourtheme/includes/admin.php, you're actually including wp-admin/includes/admin.php, so pass a full path to the require statement rather than a relative one e.g.:

  • 1
    And why did this work for public files? /wp-admin?
    – kaiser
    Commented Apr 19, 2012 at 15:41
  • it's to do with the order that PHP looks for files, remember when you're in admin the point of entry is inside the wp-admin folder, whereas for frontend it's one folder up. I imagine if there was an includes/admin.php in the same folder as wp-config.php it would also fail for the same reason without the above fix
    – Tom J Nowell
    Commented Apr 19, 2012 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.