wp_get_attachment_link WordPress Filter Hook

The wp_get_attachment_link hook allows you to filter the HTML output for attachment links. This can be useful for modifying the link text or adding custom data to the link.

apply_filters( 'wp_get_attachment_link', string $link_html, int|WP_Post $id, string|int[] $size, bool $permalink, bool $icon, string|false $text, array|string $attr ) #

Filters a retrieved attachment page link.


Parameters

$link_html

(string)The page link HTML output.

$id

(int|WP_Post)Post ID or object. Can be 0 for the current global post.

$size

(string|int[])Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).

$permalink

(bool)Whether to add permalink to image. Default false.

$icon

(bool)Whether to include an icon.

$text

(string|false)If string, will be link text.

$attr

(array|string)Array or string of attributes.


Top ↑

Source

File: wp-includes/post-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.1.0Added the $attr parameter.
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.