I will ask for help as I'm going nuts trying to figure out what is going on here. I've read many other questions but there is never a final answer.
I want to organize my WP installation in a different way:
public_html/
-> content/
|--> plugins/
|--> themes/
-> core/
|--> wp-includes/
|--> wp-admin/
|--> etc
-> uploads/
-> wp-config.php
-> index.php
This structure is based and adapted from this article and WordPress-Skeleton.
Everything is fine until the moment I want to specify the UPLOADS directory. If I didn't try to, it would be inside content
. But in the moment I define it, it becomes a directory inside -> core/
.
The behaviour seems to be erratic, as I had it working at the beginning, and then it stopped working. Cache is disabled. This is my wp-config.php
(the part to be edited):
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/documentation/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
define( 'WP_DEVELOPMENT_MODE', 'all' );
define( 'WP_CACHE', false );
/* Add any custom values between this line and the "stop editing" line. */
define( 'WP_SITEURL', 'https://staging.mywebsite.com/core' );
define( 'WP_HOME', 'https://staging.mywebsite.com' );
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/content' );
define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
define( 'UPLOADS', 'uploads' );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
And there are two important WP options to mention as well: upload_url_path
and upload_path
.
upload_url_path = https://staging.mywebsite.com/uploads
The value for this first one makes sense, right? It's the URL I want for my uploads folder (outside wp-content
, named content
in my case).
upload_path = uploads
And then this value is supposed to be the same thing as the UPLOADS constant defined in wp-config.php
. Default value is wp-content/uploads
, so if I want the uploads folder at the same level as the wp-content
folder, giving it the value uploads
seems to make sense.
This can be argued, because I think it is also supposed to be part of the ABSPATH (the WordPress directory), and since the content directory has been moved above the ABSPATH the relative path may not be the same anymore.
Anything I declare in define( 'UPLOADS', 'uploads' );
is being appended to https://staging.mywebsite.com/core/. So trying to navigate from there with something such as define( 'UPLOADS', '../uploads' );
ends up as this:
https://staging.mywebsite.com/core/../uploads/2024/02/image.png
which... we don't want. It works though! But it doesn't look good and seems dodgy.
Is there any clear and concise way to move the uploads
directory above the WordPress installation directory and outside the content directory?