函数文档

adjacent_image_link()

💡 云策文档标注

概述

adjacent_image_link() 函数用于显示具有相同父文章的相邻图像链接,包括下一个或上一个图像。它基于全局 $post 对象获取当前附件。

关键要点

  • 函数用于输出相邻图像链接,支持控制方向、图像尺寸和链接文本。
  • 参数包括 $prev(布尔值,控制显示上一个或下一个链接,默认为 true)、$size(图像尺寸,接受注册的尺寸名称或像素数组,默认为 'thumbnail')和 $text(链接文本,默认为 false)。
  • 函数内部调用 get_adjacent_image_link() 来获取链接,并直接输出结果。
  • 自 WordPress 2.5.0 版本引入,相关函数包括 get_adjacent_image_link()。

📄 原文内容

Displays next or previous image link that has the same post parent.

Description

Retrieves the current attachment object from the $post global.

Parameters

$prevbooloptional
Whether to display the next (false) or previous (true) link.

Default:true

$sizestring|int[]optional
Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default 'thumbnail'.
$textbooloptional
Link text.

Default:false

Source

function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false ) {
	echo get_adjacent_image_link( $prev, $size, $text );
}

Changelog

Version Description
2.5.0 Introduced.