update_attached_file


update_attached_file ( $attachment_id, $file )

Parameters:
  • (int) attachment_id Attachment ID.
  • (string) file File path for the attachment.
Returns:
  • (int|bool) Meta ID if the `_wp_attached_file` key didn't exist for the attachment. True on successful update, false on failure or if the `$file` value passed to the function is the same as the one that is already in the database.
Defined at:

Description

Updates attachment file path based on attachment ID.Used to update the file path of the attachment, which uses post meta name `_wp_attached_file` to store the path of the attachment.

Related Functions

get_attached_file, wp_delete_attachment_files, update_archived, update_meta_cache, update_page_cache

Top Google Results

User discussions

wpseek mobile