wp_get_attachment_link_attributes
Filter HookDescription
Filters the list of attachment link attributes.Hook Information
File Location |
wp-includes/post-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1687 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$attributes
|
An array of attributes for the link markup, keyed on the attribute name. |
int
|
$id
|
Post ID. |
Usage Examples
Basic Usage
<?php
// Hook into wp_get_attachment_link_attributes
add_filter('wp_get_attachment_link_attributes', 'my_custom_filter', 10, 2);
function my_custom_filter($attributes, $id) {
// Your custom filtering logic here
return $attributes;
}
Source Code Context
wp-includes/post-template.php:1687
- How this hook is used in WordPress core
<?php
1682 *
1683 * @param array $attributes An array of attributes for the link markup,
1684 * keyed on the attribute name.
1685 * @param int $id Post ID.
1686 */
1687 $attributes = apply_filters( 'wp_get_attachment_link_attributes', array( 'href' => $url ), $_post->ID );
1688
1689 $link_attributes = '';
1690 foreach ( $attributes as $name => $value ) {
1691 $value = 'href' === $name ? esc_url( $value ) : esc_attr( $value );
1692 $link_attributes .= ' ' . esc_attr( $name ) . "='" . $value . "'";
PHP Documentation
<?php
/**
* Filters the list of attachment link attributes.
*
* @since 6.2.0
*
* @param array $attributes An array of attributes for the link markup,
* keyed on the attribute name.
* @param int $id Post ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post-template.php
Related Hooks
Related hooks will be displayed here in future updates.