Content directories in non-standard locations

Note: In the usual case, WordShell will automatically detect a non-standard location for your content directory. But, the following information may be useful in any case to learn more about how WordShell works.

By default, WordPress keeps its content in a directory called wp-content. However, it is possible to move this directory – you may wish to do this to prevent automated analysis of your site (e.g. checking for the existence of lots of common plugins), or to store your modifiable content on a different filesystem.

The normal way this is done is via defining the constants WP_CONTENT_DIR and WP_CONTENT_URL in your WordPress configuration file (wp-config.php), with a couple of lines like this:

define ( 'WP_CONTENT_DIR', ABSPATH . 'site-files' );
define ( 'WP_CONTENT_URL', 'http://example.com/site-files' );

Since WordShell tries (though you can over-ride this) to do as much as possible by manipulating only files, and not to run any PHP (to maximise its chances of success on broken sites etc.), it needs to be told if the content is not in the wp-content directory. You can do this in three ways:

  1. Use the –contentdir switch on the command line. In the above example, you would add –contentdir=site-files to any WordShell command involving such a site, e.g.:wordshell mysite contact-form-7 –latest –contentdir=site-files

    That’s a bit tedious, of course.

  2. Use a site option in the configuration file. This means that WordShell will permanently know about the directory’s location. A site option can be used for any valid command-line option, including that above. To set the above permanently for the site, add this to the configuration file (use “wordshell –editrc”):siteopt#mysite#–contentdir=site-files–justwp

    Follow this link to see the manual section about site options.

  3. Have it automatically detected for you. When WordShell operates on a site (and you’ve not specified –disableremotecli), it will seek to detect the need for a site option as above, and ask if you want to add it automatically. You will get asked this question:The remote site reports that its content directory is not found at the default location (wp-content), but at site-files – do you wish to note this in our local configuration (y is strongly recommended) (y/n):

    Just answer with ‘y’, and all should be well.

Next read:

Leave a Reply

Tax country

Taxes will be calculated using the country you choose here.

Cart

Meta

  • Your profile

Recent Comments