首页 WordPress函数大全 get_attached_file()

get_attached_file()

2020-05-01 / 4930阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

get_attached_file( int $attachment_id, bool $unfiltered = false )

Retrieve attached file path based>

Contents

  • Description
    • Parameters
    • Return
    • Source
    • Changelog
  • Related
    • Uses
    • Used By
  • User Contributed Notes

描述

By default the path will go through the ‘get_attached_file’ filter, but passing a true to the $unfiltered argument of get_attached_file() will return the file path unfiltered.

The function works by getting the single post meta name, named ‘_wp_attached_file’ and returning it. This is a convenience function to prevent looking up the meta name and provide a mechanism for sending the attached filename through a filter.

参数

$attachment_id

(int)
(Required)
Attachment ID.

$unfiltered

(bool)
(Optional)
Whether to apply filters.

Default value: false

返回

(string|false) The file path to where the attached file should be, false otherwise.

大家谈论
    我的见解