attachment_link WordPress Filter Hook

The attachment_link hook is used to modify the URL of an attachment. This can be useful for changing the link to point to a different file, or for adding extra parameters to the URL.

apply_filters( 'attachment_link', string $link, int $post_id ) #

Filters the permalink for an attachment.


Parameters

$link

(string)The attachment's permalink.

$post_id

(int)Attachment ID.


Top ↑

Source

File: wp-includes/link-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.6.0Providing an empty string will now disable the view attachment page link on the media modal.
2.0.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.

Show More
Show More