Displays an attachment page link using an image or icon.
$postint|WP_Postoptional
$fullsizebooloptional
Default:false
$deprecatedbooloptional
Default:false
$permalinkbooloptional
Default:false
Outputs an HTML hyperlink to an attachment file or page, containing either
If no attachment can be found, the function displays the string Missing Attachment.
Use wp_get_attachment_link() instead if you just want to get the hyperlink, not print it.
function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.5.0' );
}
if ( $fullsize ) {
echo wp_get_attachment_link( $post, 'full', $permalink );
} else {
echo wp_get_attachment_link( $post, 'thumbnail', $permalink );
}
}
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/the_attachment_link