1

I have a custom Wordpress file-structure like

web-root:

  • content (folder)

    • uploads (folder)
    • plugins (folder)
    • themes (folder) ... and so on
  • wordpress (folder)

    • wp-admin (folder)
    • wp-includes (folder) ... more folders
    • wp-blog-header.php
    • wp-load.php
    • wp-login.php ... and all other wp core files

.htaccess

index.php

wp-config.php

In my wp-config.php I have to define the path to my custom uploads folder like this:

if (!defined('UPLOADS')) {
    define('UPLOADS', '../content/uploads');
}

More or less out of nothing (maybe I updated the wp core) when trying to upload an image I get the error message saying: can't create folder check if parent folder is writeable.

BUT: if I put the same code into the wp-blog-header.php file uploading and building new folders within the upload folder works.

I thought using DEFINE(in my case) means that I just save a string value to a constant and where ever I use the constant the value is the same. But how can it be that there is a difference when defining a constant in wp-config.php or wp-blog-header.php? (which is inside the subfolder wordpress .

For my changes in wp-blog-header.php would disappear after the next Wordpress update I obviously can't solve it that way.

Any ideas what the problem could be?

6
  • Can you try an absolute path instead of the relative one?
    – kero
    Nov 7, 2019 at 10:44
  • Shouldn't it just be 'content/uploads' ? Since wp-config.php is within the root. Nov 7, 2019 at 10:57
  • @kero the path has to be relative because wordpress puts abspath before that
    – Luckyfella
    Nov 7, 2019 at 11:01
  • @BasvanDijk because wordpress works inside the subfolder the abspath points to the subfolder and this way you have to go up one folder-level first
    – Luckyfella
    Nov 7, 2019 at 11:03
  • 2
    @Luckyfella Since plugins and themes are in there as well, can't you just set WP_CONTENT_DIR?
    – kero
    Nov 7, 2019 at 11:05

1 Answer 1

0

(Converting my comment to an answer.)

Since you store themes and plugins in that folder as well, try setting the WP_CONTENT_DIR constant instead. (Always prefer absolute paths when possible.)

As to your specific case, why it worked in one file but not in another - this will probably involve more debugging, checking where exactly WP uses which constant, etc. If setting WP_CONTENT_DIR solves your problem, remove UPLOADS and work with it.

Your Answer

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

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