adjacent_image_link() WordPress Function

The adjacent_image_link() function in WordPress allows you to get the next or previous image attachment in the same post. This is useful for creating a gallery or for displaying a series of images in a post.

adjacent_image_link( bool $prev = true, string|int[] $size = 'thumbnail', bool $text = false ) #

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


Description

Retrieves the current attachment object from the $post global.


Top ↑

Parameters

$prev

(bool)(Optional) Whether to display the next (false) or previous (true) link.

Default value: true

$size

(string|int[])(Optional) Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order).

Default value: 'thumbnail'

$text

(bool)(Optional) Link text.

Default value: false


Top ↑

Source

File: wp-includes/media.php

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


Top ↑

Changelog

Changelog
VersionDescription
2.5.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