WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/update attached file

Description

Update 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.

Note: This does not move the file. This simply updates the '_wp_attached_file' post meta after a move.

Usage

<?php update_attached_file$attachment_id$file ?>

Parameters

$attachment_id
(integer) (required) Attachment ID
Default: None
$file
(string) (required) File path for the attachment
Default: None

Return Values

(boolean) 
False on failure, true on success.

Examples

Notes

  • Uses: apply_filters() to add update_attached_file() on $file and $attachment_id.

Change Log

Since: 2.1.0

Source File

update_attached_file() is located in wp-includes/post.php

Related

See also index of Function Reference and index of Template Tags.