wp_get_attachment_url
Filter HookDescription
Filters the attachment URL.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 6939 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$url
|
URL for the given attachment. |
int
|
$attachment_id
|
Attachment post ID. |
Usage Examples
Basic Usage
<?php
// Hook into wp_get_attachment_url
add_filter('wp_get_attachment_url', 'my_custom_filter', 10, 2);
function my_custom_filter($url, $attachment_id) {
// Your custom filtering logic here
return $url;
}
Source Code Context
wp-includes/post.php:6939
- How this hook is used in WordPress core
<?php
6934 * @since 2.1.0
6935 *
6936 * @param string $url URL for the given attachment.
6937 * @param int $attachment_id Attachment post ID.
6938 */
6939 $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
6940
6941 if ( ! $url ) {
6942 return false;
6943 }
6944
PHP Documentation
<?php
/**
* Filters the attachment URL.
*
* @since 2.1.0
*
* @param string $url URL for the given attachment.
* @param int $attachment_id Attachment post ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.