WPDev.one
Core Function
View Source on Trac ↗

update_attached_file()

update_attached_file( mixed $attachment_id, mixed $file )

Updates attachment file path based on attachment ID.

Parameters 2 required

Name / Type Description
$attachment_id
int

Attachment ID.

Required
$file
string

File path for the attachment.

Required

Return Value

((int)
(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.

Function Information

Since Version
2.1.0
Source File
wp-includes/post.php
Advertisement