How to use Wordpess built-in Functions externally (in posts, widgets etc.)

For our canvas lets use the Enhanced Text Widget plugin, it will let us type Javascript, Flash and even Php directly into the text box..

After you install put this widget box on your sidebar or wherever you insert the following at the top of your code.

require( '/home/my/absolute/path/wp-load.php' );

Here is a simple example which would output something along the lines of : “Hello World Mr facade”.

IMPORTANT: Remember to change the absolute path to the one for YOUR server.

require( '/home/my/absolute/path/wp-load.php' );
echo "hello world Mr ";
$current_user = wp_get_current_user();
echo $current_user->display_name;


WordPress Codex (get current user) :