Answers:
这是您从函数中得到的结果:
Array
(
[path] => C:\development\xampp\htdocs\example.com/content/uploads/2012/04
[url] => http://example.com/content/uploads/2012/04
[subdir] => /2012/04
[basedir] => C:\~\example.com/content/uploads
[baseurl] => http://example.com/content/uploads
[error] =>
)
因此,您可以使用(如@OneTrickPony所指出的)获取文件夹/目录名称
echo wp_basename( $uploads['baseurl'] );
如果您正在运行多站点并且定义了常量UPLOADS
,则可以从UPLOADS
或访问它BLOGUPLOADDIR
。
编辑
对于多站点,您将获得以下内容:
Array
(
[path] => /var/www/example.com/public_html/wp-content/uploads/sites/2/2016/12,
[url] => http://example.com/wp-content/uploads/sites/2/2016/12,
[subdir] => /2016/12,
[basedir] => /var/www/example.com/public_html/wp-content/uploads/sites/2,
[baseurl] => http://example.com/wp-content/uploads/sites/2,
[error] => ,
)
后面的“ 2” sites
是博客的ID
basename($uploads['baseurl'])
?