WordPress at a glance

the_attachment_link() WP 1.0

Display an attachment page link using an image or icon.

Works based on: wp_get_attachment_link()
✈ 1 time = 0.00291s = very slow | 50000 times = 5.22s = fast | PHP 7.1.2, WP 4.7.3

No Hooks.

Return

Null. Nothing.

Usage

the_attachment_link( $id, $fullsize, $deprecated, $permalink );
$id(int/WP_Post)
Post ID or post object.
Default: 0
$fullsize(true/false)
Whether to use full size.
Default: false
$deprecated(true/false)
Deprecated. Not used.
Default: false
$permalink(true/false)
Whether to include permalink.
Default: false

Changelog

Since 2.0.0 Introduced.

Code of the attachment link: wp-includes/post-template.php WP 5.2.3

<?php
function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.5.0' );
	}

	if ( $fullsize ) {
		echo wp_get_attachment_link( $id, 'full', $permalink );
	} else {
		echo wp_get_attachment_link( $id, 'thumbnail', $permalink );
	}
}

Related Functions

From tag: Link (tag A in HTML)

More from category: Attachments (Media files)

More from Template Tags: Post Thumbnails

No comments
    Hello, !     Log In . Register