我正在使用此代码列出帖子的图像附件:
<select name="chb_homes_for_sale_specifics_floor_plan" style="width:100%;">
<option value="">Select</option>
<?php
$args = array(
\'numberposts\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'post_type\' => \'attachment\',
\'post_parent\' => $post->ID,
\'post_mime_type\' => \'image\'
);
$image = get_posts($args);
if($image) {
foreach($image as $key => $data) : ?>
<option value="<?php echo $data->ID; ?>"><?php echo $data->post_title; ?></option>
<?php endforeach;
}
?>
</select>
但我现在展示的是附件post_title
但是我想显示文件名。我可能会使用获取附件URL,然后解析URL来获取文件名,但我想知道WordPress中是否有现成的方法来获取文件名。