Title: adjacent_post_link
Published: April 25, 2014
Last modified: May 20, 2026

---

# adjacent_post_link( string $format, string $link, bool $in_same_term = false, int[]|string $excluded_terms = '', bool $previous = true, string $taxonomy = 'category' )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#wp--skip-link--target)

Displays the adjacent post link.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#description)󠁿

Can be either next post link or previous.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#parameters)󠁿

 `$format`stringrequired

Link anchor format.

`$link`stringrequired

Link permalink format.

`$in_same_term`booloptional

Whether link should be in the same taxonomy term.

Default:`false`

`$excluded_terms`int[]|stringoptional

Array or comma-separated list of excluded category IDs.

Default:`''`

`$previous`booloptional

Whether to display link to previous or next post.

Default:`true`

`$taxonomy`stringoptional

Taxonomy, if `$in_same_term` is true. Default `'category'`.

Default:`'category'`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#source)󠁿

    ```php
    function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
    	echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/link-template.php#L2416)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/link-template.php#L2416-L2418)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#related)󠁿

| Uses | Description | 
| [get_adjacent_post_link()](https://developer.wordpress.org/reference/functions/get_adjacent_post_link/)`wp-includes/link-template.php` |

Retrieves the adjacent post link.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/adjacent_post_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadjacent_post_link%2F)
before being able to contribute a note or feedback.