Title: wp-load.php
Last modified: June 27, 2019

---

# wp-load.php

 *  Resolved [nikdow](https://wordpress.org/support/users/nikdow/)
 * (@nikdow)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/)
 * Your ajax script loads wp-load.php with this statement:
    require_once ( dirname(
   dirname( dirname( dirname( __FILE__ ) ) ) ) . ‘/wp-load.php’ ); This fails if
   wp-content/plugins has been moved to a non-standard location. I’ve extracted 
   a few lines from the settings table to illustrate our set up below: ABSPATH WP
   absolute path. /home/lamp/wordpress/core/wp5.2.1/ WPPA_ABSPATH ABSPATH windows
   proof /home/lamp/wordpress/core/wp5.2.1/ WPPA_PATH Path to plugins directory./
   home/lamp/wordpress/wp-content/www.otu.asn.au/plugins/wp-photo-album-plus WPPA_NAME
   Plugins directory name. wp-photo-album-plus WPPA_URL Plugins directory URL. [https://www.otu.asn.au/wp-content/plugins/wp-photo-album-plus](https://www.otu.asn.au/wp-content/plugins/wp-photo-album-plus)
   WPPA_UPLOAD The relative upload directory. wp-content/www.otu.asn.au/uploads 
   WPPA_UPLOAD_PATH The upload directory path. /home/lamp/wordpress/core/wp5.2.1/
   wp-content/www.otu.asn.au/uploads/wppa
 * If I replace the above line with
    require_once ( ‘/home/lamp/webroot/otu/wp-load.
   php’ ); and in wp-config I add: define(‘WPPA_REL_UPLOADS_PATH’, ‘wp-content/www.
   otu.asn.au/uploads’); define(‘WPPA_REL_DEPOT_PATH’, ‘wp-content/www.otu.asn.au’);
   Then everything works. So you do have support for moving wp-content/uploads but
   not support for moving the plugins directory.
 * Our set up works with these redirects:
    RewriteCond %{REQUEST_URI} !^/wp-content/
   www.otu.asn.au/(.*) RewriteCond %{REQUEST_URI} ^/wp-content/(.*) RewriteRule 
   ^/wp-content/(.*) /wp-content/%{SERVER_NAME}/%1
 * We have a large number of small WP websites sharing a server. They share WP core
   code and some common/large plugins. All this optimises use of OPCache memory.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fwp-load-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Jacob N. Breetvelt](https://wordpress.org/support/users/opajaap/)
 * (@opajaap)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11679435)
 * The problem is that wp-load.php defines ABSPATH, so how should i know where wp-
   load.php resides? If you know an answer to this, i can change it.
 *  Thread Starter [nikdow](https://wordpress.org/support/users/nikdow/)
 * (@nikdow)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11680668)
 * Could you do some fall-back error handling and check $_SERVER[‘DOCUMENT_ROOT’]
   if the include fails?
 * /** Load WordPress Bootstrap */
    $inc = dirname( dirname( dirname( dirname( __FILE__)))).‘/
   wp-load.php’; if (file_exists($inc) && is_readable($inc)) { require_once( $inc);}
   else { require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-load.php’ ); }
 *  Plugin Author [Jacob N. Breetvelt](https://wordpress.org/support/users/opajaap/)
 * (@opajaap)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11682395)
 * Using $_SERVER[‘DOCUMENT_ROOT’] is not a good idea.
 * On my dev site, `$_SERVER['DOCUMENT_ROOT']` is:
    `/home/..../http/premium/rid/../../
   51893315/htdocs` while `ABSPATH` is `/home/..../http/premium/rid/../../51893315/
   htdocs/opajaap/betatest/`
 * Why don’t you simply turn off using the front-end ajax interface, falling back
   to the ‘normal’ wp ajax interface?
 * To do so:
    – Untick **Table IV-A1.1**: Ajax NON Admin _Frontend ajax use no admin
   files._ – Make sure you do not prevent http access to `ABSPATH . 'wp-admin/admin-
   ajax.php'` with your .htaccess files.
 *  Thread Starter [nikdow](https://wordpress.org/support/users/nikdow/)
 * (@nikdow)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11684278)
 * Thanks for your help.
 * The error is occuring in a page that is provided by a plugin written by us some
   time ago. Our plugin uses Angular 1. I had to review our plugin to solve this
   problem. It contained this code:
 *     ```
       var ajaxurl = $scope.data.siteurl + "/wp-content/plugins/wp-photo-album-plus/wppa-ajax-front.php?action=wppa&wppa-action=render&wppa-cover=0&wppa-album=" + $scope.item.album + "&wppa-occur=1&wppa-size=640";
       wppaDoAjaxRender( 1, ajaxurl, '' )
       ```
   
 * I replaced this with
 *     ```
       var ajaxurl = $scope.data.ajaxurl + "?action=wppa&wppa-action=render&wppa-cover=0&wppa-album=" + $scope.item.album + "&wppa-occur=1&wppa-size=640";
       wppaDoAjaxRender( 1, ajaxurl, '' )
       ```
   
 * The problem was solved.
 * The JS variables are provided by the plugin PHP:
 *     ```
       $data['ajaxurl'] = admin_url('admin-ajax.php');
       $data['siteurl'] = get_site_url();
       ```
   
 *  Thread Starter [nikdow](https://wordpress.org/support/users/nikdow/)
 * (@nikdow)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11684281)
 * Now closed this Topic, thanks for your help which pointed me to the solution.
 *  Plugin Author [Jacob N. Breetvelt](https://wordpress.org/support/users/opajaap/)
 * (@opajaap)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11684284)
 * you’re welcome

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘wp-load.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-photo-album-plus.svg)
 * [WP Photo Album Plus](https://wordpress.org/plugins/wp-photo-album-plus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-photo-album-plus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-photo-album-plus/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-photo-album-plus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-photo-album-plus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-photo-album-plus/reviews/)

## Tags

 * [plugins directory](https://wordpress.org/support/topic-tag/plugins-directory/)
 * [wp-load.php](https://wordpress.org/support/topic-tag/wp-load-php/)

 * 6 replies
 * 2 participants
 * Last reply from: [Jacob N. Breetvelt](https://wordpress.org/support/users/opajaap/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/wp-load-php/#post-11684284)
 * Status: resolved