WordPress附件存放目录格式修改为年/月/日

WordPress默认的附件存放目录格式为年/月/,但这对于含有大量图片的Wordpress博客显然不合适,一个目录下可能有上万张图片,这也是许多虚拟主机运营商不允许的。

那么我们可以将Wordpress默认的附件存放目录格式修改为年/月/日/,就可以更有条理的组织附件目录了。

修改wp-includes/functions.php文件的下面这几句代码,

$subdir = ";
if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
// Generate the yearly and monthly dirs
if ( !$time )
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$subdir = "/$y/$m";
}

修改为如下代码(增加蓝色的部分)

$subdir = ";
if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
// Generate the yearly and monthly dirs
if ( !$time )
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
 $d = substr( $time, 8, 2 );
$subdir = "/$y/$m/$d";
}

发表回复

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