Basically I want to use wordpress functions for example wp_create_user() or wp_update_user() outside of wordpress (outside of wordpress directory).

I tried with all the below code snippets to load the wordpress environment, I am able to use the functions correctly in both the cases but the problem is that this also loads the wordpress template which I do not want.

First Method:

define('WP_USE_THEMES', false);
require ('../blog/wp-load.php');

Second Method:

define('WP_USE_THEMES', false);
require ('../blog/wp-blog-header.php');

Directory Structure:

  |_ Wordpress installed here
  |_ admin.php (I want to use wp functions here)

Note: I am using Writr theme in my wordpress blog.

  • what is your filename and where it is located relative to your wordpress setup ?
    – Shazzad
    Dec 21, 2013 at 8:32

4 Answers 4


If you place the file in the WP root directory, e.g. http://mysite.com/myscript.php

require( dirname(__FILE__) . '../blog/wp-load.php' );
if (function_exists('wp_create_user')) {
    echo "wp_create_user() found";

If you are in a different directory, just make sure you are loading wp-load.php from the proper location.

  • I have mentioned the directory structure in my question, you can give the answer accordingly.Thanks
    – Ram Patra
    Dec 21, 2013 at 18:59

Yes and to do such a thing you can use something like this :

// load only basics
if ( SHORTINIT ) return false;

EDIT: I've found this constant. If set WordPress initializes to a minimum

  • tried, not working. The wp theme is being loaded.
    – Ram Patra
    Dec 21, 2013 at 11:03
  • I've edited code.
    – JMau
    Dec 21, 2013 at 13:34
  • still not working
    – Ram Patra
    Dec 21, 2013 at 15:25
  • I've edited code again ^^
    – JMau
    Dec 25, 2013 at 13:54

The functions.php of the theme was breaking the html of my other page. That's what I did and solved my problem:

define('STYLESHEETPATH', '');
define('TEMPLATEPATH', '');

Well I don't know the reason how this worked but it did.

At first, I was loading the wp environment in the beginning of my file and it was loading the wp template(wp theme) which I didn't want.

But now I loaded the wp environment at the end of the file and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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