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?
Leave a Reply
You must be logged in to post a comment.
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).The simplest way is include
wp-load.php
file. This file will loads all WP core, so you can use WP functions such asget_option
in your PHP file:Turn your external file into a WordPress plugin. That way you’ll have full access to WP core functions.
This should work on any WordPress installation: