How to load WordPress on non WP page?

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?

4

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' );

Leave a Comment