Title: problems with wp in sub-folder
Last modified: August 30, 2016

---

# problems with wp in sub-folder

 *  Resolved [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/)
 * Hi! My wp folder structure is like the following:
 *     ```
       index.php
       —content/
         —plugins/
         —themes/
       —core/
         —wp-admin/
         —wp-includes/
       ```
   
 * this causes an error with your plugin:
 *     ```
       <b>Fatal error</b>:  require(): Failed opening required '/site/wp-includes/ms-functions.php' in 'site/content/plugins/shariff/backend/index.php' on line 50
       ```
   
 * Any ideas to solve this dynamically?
 * P.s.: First, of course enjoy your holidays 🙂
 * [https://wordpress.org/plugins/shariff/](https://wordpress.org/plugins/shariff/)

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/page/2/?output_format=md)

 *  Plugin Author [3UU](https://wordpress.org/support/users/3uu/)
 * (@3uu)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487508)
 * There was a commit at Github bei “hirasso” that will fix this problem. Code looks
   well but I have not tested it. However we this functionality will be part of 
   the next release.
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487514)
 * > There was a commit at Github bei “hirasso”
 * actually, hirasso is me on github 😉
 * hopefully my fix works for others as well. Tested it at least with my environment.
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487516)
 * Changed my name here to match my github profile. No more confusion.
 *  Plugin Author [Jan-Peter](https://wordpress.org/support/users/starguide/)
 * (@starguide)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487614)
 * Hi hirasso,
 * thank you for the commit. As far as I can tell right now, it works fine. There
   is just a slight thing that I don’t like about it: It costs performance for basically
   nothing. The backend is called every time somebody visits your page and for every
   group of buttons on that page (e.g. on the blog overview page). And every time
   it searches for the wp-load.php – even though it never changes. That is quite
   a costly action for not much of a gain. My suggestion would probably be to create
   another constant that you can define in the wp-config.php to determine where 
   the wp-load.php is, in case it has been moved. Like we already do it, if somebody
   wants to use a different cache directory. If someone changes the standard folder
   structure of WordPress, that person probably won’t have a problem to add a line
   to the wp-config.php, I guess.
 * I could even add a note to the status section, in case the wp-load.php is in 
   a different place as expected, that tells the people what they have to do.
 * What do you think?
 * Cheers,
    JP
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487616)
 * Hi JP,
 * your solution with the constant actually sounds like a better idea indeed! Another
   good solution could be to apply a filter to the wp-load location. That way users
   could control it from their themes functions.php file.
 *  Plugin Author [Jan-Peter](https://wordpress.org/support/users/starguide/)
 * (@starguide)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487617)
 * The problem with filters is that WP is not loaded at that point, so there is 
   no way of determined the path (except for searching) prior to loading at least
   the wp-load.php. But anyways, I’ll add the constant solution with a nice note
   in the status section with the next release. That should take care of the issue
   and has no impact on the performance. I’ll let you know as soon as it is implemented
   for you to test it.
 * JP
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487618)
 * ah, of course, I actually first tried it with a filter! I’m so used to wp being
   present that I keep forgetting that 😉
 * Excited to see the next release soon, thanks so much for your effort! 🙂
 *  Plugin Author [Jan-Peter](https://wordpress.org/support/users/starguide/)
 * (@starguide)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487664)
 * Hey,
 * only two month later and we finally have a new version approaching… Anyways, 
   the new constant solution is part of it. So you might already want to prepare
   for it by setting the new constant in your wp-config.php.
 * `define('SHARIFF_WP_ROOT_PATH', '/path/to/wordpress/');`
 * After the update it should then work right away out of the box.
 * JP
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487665)
 * Hey JP,
 * just in time! we yesterday released the website that uses your plugin.
 * [http://schloss-post.com/](http://schloss-post.com/)
 * Will check if it works and report back.
 *  Plugin Author [Jan-Peter](https://wordpress.org/support/users/starguide/)
 * (@starguide)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487666)
 * Hey hirasso,
 * well, sometimes you really don’t see what is in front of you. The constant works,
   but of course not in the wp-config.php, because if we cannot find WordPress, 
   we cannot find the wp-config.php as well. Doh! So I created an own config-file
   for our plugin in the plugin directory called shariff-config.php where you can
   set the constant. So after the update you need to edit this file once to include
   your path and then everything should be fine.
 * 3UU is checking the code on Saturday (always a good thing to have someone else
   review your code) and will then release the new version.
 * JP
 *  Plugin Author [3UU](https://wordpress.org/support/users/3uu/)
 * (@3uu)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487667)
 * Version 3.1 with the new backend is online now. This has not the final solution
   because the config file has to get an update with every new version. However 
   if this way works for you I have an idea how we can fix the problem and make 
   a permanent solution.
 *  Plugin Author [Jan-Peter](https://wordpress.org/support/users/starguide/)
 * (@starguide)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487668)
 * Well actually, since we implemented hirassos search solution to set the constant
   it should work right out of the box.
 * @hirasso let us know, if it works.
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487675)
 * Hi there, it still isn’t working. I also can’t find my contributed code inside
   the `backend/index.php` file. Running the latest version.
 * EDIT: Now I found my code, but somehow it returns NULL on my install. *puzzled*
   will report back
 *  Thread Starter [Rasso Hilber](https://wordpress.org/support/users/nonverbla/)
 * (@nonverbla)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487676)
 * So… I think I found the fix (don’t really understand the code though, but it 
   works now on my server).
    Replace line 64 in backend/index.php with
 *     ```
       $iterator = new RecursiveIteratorIterator( $dir );
       ```
   
 *  Plugin Author [3UU](https://wordpress.org/support/users/3uu/)
 * (@3uu)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/#post-6487677)
 * Aua, you are right. Not sure why I did not see it at the review 🙁 However in
   function
 * `rsearch($folder, $pattern) {`
 * I do not see why
 *     ```
       $dir = new RecursiveDirectoryIterator($folder);
       $iterator = new RecursiveIteratorIterator($dir);
       $files = new RegexIterator($iterator, $pattern, RegexIterator::GET_MATCH);
       ```
   
 * is needed. Would
 * `$iterator = new RecursiveIteratorIterator($folder)`
 * not work too?

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/page/2/?output_format=md)

The topic ‘problems with wp in sub-folder’ is closed to new replies.

 * ![](https://ps.w.org/shariff/assets/icon.svg?rev=2006307)
 * [Shariff Wrapper](https://wordpress.org/plugins/shariff/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shariff/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shariff/)
 * [Active Topics](https://wordpress.org/support/plugin/shariff/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shariff/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shariff/reviews/)

 * 20 replies
 * 3 participants
 * Last reply from: [Jan-Peter](https://wordpress.org/support/users/starguide/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/problems-with-wp-in-sub-folder/page/2/#post-6487684)
 * Status: resolved