时间:2024-03-09
WordPress函数get_attached_file根据附件的ID返回对应附件的完整路径。
get_attached_file( int $attachment_id, bool $unfiltered = false )
$attachment_id
整数
附件ID
$unfiltered
布尔值,默认值:false
是否应用过滤器。
/home/tiezhushuo/htdocs/wordpress/wp-content/uploads/2020/10/theme-tiezhushuo.webp
$attachment_id = 3645; $path = get_attached_file($attachment_id); $filename = basename($path);
get_attached_file()函数位于:wp-includes/post.php
相关函数:
wp_get_upload_dir()
get_post_meta()
wp_attachment_is()
Copyright © 2019-2024 79956.com