WordPress 3.5以上的版本,隐藏了后台的媒体(Media)设置页面 上传路径(upload_path)和文件 URL 地址(upload_url_path)的设定。

直接将下面的代码添加到主题的 functions.php,就可以恢复设置界面了:

if(get_option(\'upload_path\')==\'src="/wp-content/uploads\' || get_option(\'upload_path\')==null) {
update_option(\'upload_path\',WP_CONTENT_DIR.\'/uploads\');
}

推荐使用这个方法,最简单有效。

通过代码直接定义

将下面的代码添加到主题的 functions.php 的最后一个 ?> 前面:

add_filter( \'upload_dir\', \'MBT_custom_upload_dir\' );
function MBT_custom_upload_dir( $uploads ) {
 $upload_path = \'\';
 $upload_url_path = \'\';
 
 if ( empty( $upload_path ) || \'src="/wp-content/uploads\' == $upload_path ) {
 $uploads[\'basedir\'] = WP_CONTENT_DIR . \'/uploads\';
 } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
 $uploads[\'basedir\'] = path_join( ABSPATH, $upload_path );
 } else {
 $uploads[\'basedir\'] = $upload_path;
 }
 
 $uploads[\'path\'] = $uploads[\'basedir\'].$uploads[\'subdir\'];
 
 if ( $upload_url_path ) {
 $uploads[\'baseurl\'] = $upload_url_path;
 $uploads[\'url\'] = $uploads[\'baseurl\'].$uploads[\'subdir\'];
 }
 return $uploads;
}

注意修改第3、4行中$upload_path 和 $upload_url_path ,例如

$upload_path = \'img\';
$upload_url_path = \'https://img.mobantu.net\';

使用插件恢复

你可以下载安装 Ps Display Upload_path For WP3.5 插件,然后就可以在后台 – 设置 – 多媒体,看到原来的设置选项啦

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注