I'm converting my old web project to WP and there are tons of book covers that aren't to be uploaded/managed by WP but by my own functions. Where is the right place to store such a kind of custom content? For sure it has to be a new folder but where? Maybe wp-content/uploads/cover or wp-content/cover ?
WordPress has a core function
wp_upload_dir that return info for the current upload folder.
Using this function you can retrieve all info on uploads folder base on current configuration.
E.g. if you set
UPLOADS constants that function will return the direcory according to this settings.
If you have checked the option to store media based on current month, in WordPress settings you'll get that info too.
What I suggest is to use this function and appened the folder 'cover':
$upload_info = wp_upload_dir(); $covers_path = $upload_info['basedir'] . '/cover' . $upload_info['subdir']; $covers_url = $upload_info['baseurl'] . '/cover' . $upload_info['subdir'];
with standard settings, the
$covers_path will be something like:
if you have year/month organization turned off, or it will be something like
if year/month organization is turned on.
In this way:
- Your path became dynamic instead of hardcoded, and if you have to change you settings (e.g. domain, subdomain, WP folder...), for some reason in the future, you will have no problem
- You can make use of the year/month organization of uploaded images, that is very useful if you have a lot of images
Additionally, as @Rarst said in comment, if content is being added from inside WP on ongoing basis, content uploads is nearly only place that is as likely to be easy to write to as possible (otherwise native uploads don't work). Pretty much any other place in WP install needs to go through filesystem API for reliable writes.