the_attachment_link() - WordPress 函数参考中文文档

返回介绍

the_attachment_link()

发布于 2017-09-11 字数2259 浏览 850 评论 0

the_attachment_link( int|WP_Post $id,  bool $fullsize = false,  bool $deprecated = false,  bool $permalink = false )

Display an attachment page link using an image or icon.


描述


参数

$id

(int|WP_Post)
(Optional)
Post ID or post object.

$fullsize

(bool)
(Optional)
Whether to use full size.

Default value: false

$deprecated

(bool)
(Optional)
Deprecated. Not used.

Default value: false

$permalink

(bool)
(Optional)
Whether to include permalink.

Default value: false


源代码

File: wp-includes/post-template.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);
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    _deprecated_argument()
  • wp-includes/post-template.php:
    wp_get_attachment_link()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Examples

    
    <?php
    
    // Show an image at full size linked to the attachment file
    the_attachment_link( 4, true );
    
    // Show a thumbnail linked to the attachment page
    the_attachment_link( 4, false, false, true );
    
    ?>
    
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!