Title: Problems with included files when using WordPress functions
Last modified: August 19, 2016

---

# Problems with included files when using WordPress functions

 *  [Kratzy](https://wordpress.org/support/users/kratzy/)
 * (@kratzy)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/problems-with-included-files-when-using-wordpress-functions/)
 * I’m trying to write a script that uses the following WordPress functions: `wp_insert_post()`,`
   wp_create_user()` and `username_exists()`.
 * The script is located outside the WordPress root directory, so I need to manually
   include the files where these functions are defined. Using trial and error and
   looking up the source file for each function on the Codex, I came up with this:
 *     ```
       include("../wp-includes/plugin.php");
       include("../wp-includes/pluggable.php");
       include("../wp-includes/post.php");
       include("../wp-includes/user.php");
       include("../wp-includes/registration.php");
       include("../wp-includes/formatting.php");
       ```
   
 * But even this isn’t enough. I still get a weird cache class error.
 * Is there a better way to do what I’m doing? This way just seems very hacky.
 * Thanks.

Viewing 1 replies (of 1 total)

 *  [Marion Dorsett](https://wordpress.org/support/users/figmentthinking/)
 * (@figmentthinking)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/problems-with-included-files-when-using-wordpress-functions/#post-1958903)
 * So if your wordpress is installed in your webroot and you’re trying to access
   it from a subfolder, you want to do the following:
 * Include wp-load.php first, and then include the other files you’re looking for.
   Wp-load.php will setup everything the other files need for you to access the 
   functions properly.
 * include_once(‘../wp-load.php’);
 * If you find you still can’t access what you’re looking for, then include the 
   file with the missing functions.
 * include_once(ABSPATH . WPINC . ‘/plugin.php’);

Viewing 1 replies (of 1 total)

The topic ‘Problems with included files when using WordPress functions’ is closed
to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [Marion Dorsett](https://wordpress.org/support/users/figmentthinking/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/problems-with-included-files-when-using-wordpress-functions/#post-1958903)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
