With a plugin, I have used require_once in the init.php of a plugin that I have made for my site to make functions available.

With a child theme, where should I put the calls to require_once? When I put them into the template file that uses it, it doesn't seem to work.


I would have thought that this

locate_template('../../plugins/events-and-bookings/lib/class_eab_event_model.php', true, false);

Would be equivalent to this:

if (!function_exists('jupiter_init')) {
    function jupiter_init() {

But the first code snipper isn't working (but the second one is). I am placing both in the functions.php file of my child theme right after the initial


When you create a theme, you can use functions.php file for all utilize functions. Also this is the best place for all your require_once calls.

One trick I would like to recommend for theme development approach:

Don't use direct require_one call to include your scripts. Instead of it, use locate_template function to load scripts. By using this function, all child themes will be able to override your scripts. So for instance, you have file called utilize.php, and it lies in inc folder of your theme, then instead of calling require_once 'inc/utilize.php';, call locate_template( 'inc/utilize.php', true, false );.

Now it will be possible to create inc/utilize.php file in a child theme and override parent file.

| improve this answer | |
  • check out my update, I tried using require_once in my functions.php and it worked perfectly - when I put locate_template in the same spot, it didn't seem to work - – William Mar 11 '13 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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