0

I'd like to create the following structure for my WP installation:

  • htdocs (base dir)
    • wp (WordPress dir)
    • themes (WordPress theme dir)
    • plugins (WordPress plugin dir)
    • upload
    • index.php
    • .htaccess

So far I've been able to change the WordPress root directory [1] (which means that even though we're on «wp», we don't see the http://example.com/wp url, but http://example.com (without /wp, which is correct for what I want). However, my first «problem» is that, when accessing to the Dashboard, I do see the '/wp/xxx' in the url. Is that normal?

Plugins and upload folder change work fine. [2]

Themes, don't work fine [3]. I've created my own extension, where I use the register_theme_directory function in the following way:

register_theme_directory(ABSPATH . '../themes');

This makes the themes inside this themes folder show up in the themes selection section on the dashboard. I can select it and the theme is enabled, and it partially works (templates are correctly loaded). However, images don't load because WordPress tries to retrieve a wrong path:

/wp/wp-content/var/www/example.com/htdocs/wp/../themes/wp-softcatala/static/images/softcatala-logotip.jpg

(wp-softcatala is the wordpress theme)

Could anyone tell me why images are not loaded correctly? Why is it using the absolute path? (all directories have correct permissions for apache)

Thanks

1
  • Quick note: this issue with images only happens with the images from the theme folder. Images from upload folder are correctly loaded.
    – PauGNU
    Commented Aug 30, 2015 at 6:20

2 Answers 2

3

You can move the installation and also plugin and content folder. The follow source demonstrate this.

//*
// Custom content directory
define( 'WP_CONTENT_DIR',  dirname( __FILE__ ) . '/wp-content' );
define( 'WP_CONTENT_URL',  'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );
// Custom plugin directory
define( 'WP_PLUGIN_DIR',   dirname( __FILE__ ) . '/wp-plugins' );
define( 'WP_PLUGIN_URL',   'http://' . $_SERVER['HTTP_HOST'] . '/wp-plugins' );
// Custom mu plugin directory
define( 'WPMU_PLUGIN_DIR', dirname( __FILE__ ) . '/wpmu-plugins' );
define( 'WPMU_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wpmu-plugins' );
/**/

Source for the code example. https://github.com/bueltge/WordPress-Starter/blob/master/wp-config.php

2
  • Thanks, bueltge. However, I don't want to move the whole wp-content dir, I'd like to be able to implement the directory structure mentioned above. Do you consider this structure no-sense or too complex?
    – PauGNU
    Commented Aug 30, 2015 at 6:54
  • Is to complex for WordPress, you get a lot of problems with the core. Better is only plugins, content, uploads.
    – bueltge
    Commented Aug 30, 2015 at 10:09
0

After some more investigation I found that the issue might be on my Timber theme. The variable that retrieves the theme path on Timber side is not correctly set. There is already an existing bug in Timber about this:

https://github.com/jarednova/timber/issues/619#issuecomment-136096298

Your Answer

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

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