我刚刚安装了一个带有映射域的 wordpress 多站点安装(4.2.1 版)。
对于每个站点,浏览器中显示的上传图像的 url 是http://URL/wp-content/uploads/sites/SITENUMBER/DATE/...
,文件夹是/path/to/wordpress/wp-content/uploads/sites/SITENUMBER/DATE/...
. 但我想使用本地路径/path/to/wordpress/wp-content/uploads/sites/SITENUMBER/...
并想在浏览器中查看http://URL/wp-content/uploads/DATE/...
(例如在单个 wordpress 站点中)。
我已经阅读了很多关于此的内容,我想我知道“上传 URL 路径”选项通常应该重写它,不是吗?但对我来说它不起作用。我如何自定义 wordpress 以适应它?
更新:我发现在 functions.php 中定义了多站点将重写 URL:
// If multisite (and if not the main site in a post-MU network)
if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
if ( ! get_site_option( 'ms_files_rewriting' ) ) {
/*
* If ms-files rewriting is disabled (networks created post-3.5), it is fairly
* straightforward: Append sites/%d if we're not on the main site (for post-MU
* networks). (The extra directory prevents a four-digit ID from conflicting with
* a year-based directory for the main site. But if a MU-era network has disabled
* ms-files rewriting manually, they don't need the extra directory, as they never
* had wp-content/uploads for the main site.)
*/
if ( defined( 'MULTISITE' ) )
$ms_dir = '/sites/' . get_current_blog_id();
else
$ms_dir = '/' . get_current_blog_id();
$dir .= $ms_dir;
$url .= $ms_dir;
...
}}
但我不知道如何改变它以获得所需的行为。