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 want to use the get_option() function of wordpress in one of my theme's files, which is not related to WP, it is just located in the same directory of the other theme files. I need this file because of some extra IPN paypal related actions, but I need some values from the options table that exists in WP to be called in this page in order for it to work. I know I can't just use get_option() as this file is overlooked by wordpress. Is there any approach by including some parts of wordpress in my theme to make this functionality only work?

share|improve this question
I retagged your question. Hint: Just take a look inside wp-load.php. – kaiser Oct 14 '12 at 19:40

Turn your external file into a WordPress plugin. That way you'll have full access to WP core functions.

share|improve this answer
This would make your life much easier in the long run. – westondeboer Oct 14 '12 at 17:31

The simplest way is include wp-load.php file. This file will loads all WP core, so you can use WP functions such as get_option in your PHP file:

include 'path/to/wp-load.php';

echo get_option( 'option_name' );
share|improve this answer
+1 But by above answer, you can delete "the simplest" ;) – kaiser Oct 14 '12 at 19:48
One line (including wp-load.php) vs. multiple lines (plugin comments in the beginning), that's the simplest, lol. – Rilwis Oct 15 '12 at 1:16

The shortest way is to load wp-load.php and abort the loading of the template engine (Note: You couldn't do that, if you'd be loading the header file, like you see it on many sites in the interweb).

# No need for the template engine
define( 'WP_USE_THEMES', false );
# Load WordPress Core
// Assuming we're in a subdir: "~/wp-content/plugins/current_dir"
require_once( '../../../wp-load.php' );
share|improve this answer
Is there more docs on WP_USE_THEMES than codex.wordpress.org/The_Loop ? :) – jave.web May 25 at 19:27
@jave.web Sure: The source code cross file search. – kaiser May 25 at 21:37

Your Answer


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

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