Title: using require_once in functions.php
Last modified: August 19, 2016

---

# using require_once in functions.php

 *  [vonkanehoffen](https://wordpress.org/support/users/ttr738/)
 * (@ttr738)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/using-require_once-in-functionsphp/)
 * Hi,
    I have a feeling there’s going to be a really simple answer to this, but
   I can’t see it and it’s driving me mad! Hope someone can help.
 * I have a load of custom functions in my theme’s functions.php that I want to 
   shift into another file to tidy things up a bit. They deal with creating a theme
   options admin panel.
    I cut and paste these functions into said new file, and
   include it with `require_once(TEMPLATEPATH . '/filename.php');` I reload the 
   admin panel. WP gives the error “You do not have sufficient permissions to access
   this page.”
 * Why?! I’ve checked the new file’s actually being included by adding `echo "test";`
   in it, which promptly displays above the wordpress error. I’ve also checked the
   logs and PHP doesn’t throw an error.
 * Any ideas anyone? I’m completely at a loss!
 * Cheers,
    Kane

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/using-require_once-in-functionsphp/#post-1609474)
 * Then it must be something you’re calling in one of the functions..
 * I do something similar for my test install. I have a plugin which basically includes
   a pile functions from outside root (that way i can run the plugin across several
   installs and not need to keep several copies), but it’s just a simple include
   statement to a main file housing several functions. I also include another file
   inside that one because it got too big.
 * Cut out a few functions at a time and test the install, if you can narrow it 
   down to a particular function, then post the code (use a [pastebin ](http://wordpress.pastebin.com/)
   if doing so please), i can probably take a good guess at what the problem code
   is.
 *  Thread Starter [vonkanehoffen](https://wordpress.org/support/users/ttr738/)
 * (@ttr738)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/using-require_once-in-functionsphp/#post-1609810)
 * Ha! Turned out to be the line:
    `header("Location: themes.php?page=functions.
   php&saved=true);` that was the problem. Didn’t realise that even though it was
   an include, this would still need changing to: `header("Location: themes.php?
   page=the_included_file.php&saved=true);`
 * You learn something every day!
 * Thanks very very much for your reply anyway 🙂
    Sorry I didn’t get back sooner–
   I couldn’t narrow it down to a single function to put in a pastebin really!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘using require_once in functions.php’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [vonkanehoffen](https://wordpress.org/support/users/ttr738/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/using-require_once-in-functionsphp/#post-1609810)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
