get_attached_file
Filter HookDescription
Filters the attached file based on the given ID.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 848 |
Hook Parameters
Type | Name | Description |
---|---|---|
string|false
|
$file
|
The file path to where the attached file should be, false otherwise. |
int
|
$attachment_id
|
Attachment ID. |
Usage Examples
Basic Usage
<?php
// Hook into get_attached_file
add_filter('get_attached_file', 'my_custom_filter', 10, 2);
function my_custom_filter($file, $attachment_id) {
// Your custom filtering logic here
return $file;
}
Source Code Context
wp-includes/post.php:848
- How this hook is used in WordPress core
<?php
843 * @since 2.1.0
844 *
845 * @param string|false $file The file path to where the attached file should be, false otherwise.
846 * @param int $attachment_id Attachment ID.
847 */
848 return apply_filters( 'get_attached_file', $file, $attachment_id );
849 }
850
851 /**
852 * Updates attachment file path based on attachment ID.
853 *
PHP Documentation
<?php
/**
* Filters the attached file based on the given ID.
*
* @since 2.1.0
*
* @param string|false $file The file path to where the attached file should be, false otherwise.
* @param int $attachment_id Attachment ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.