Title: next_post_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# next_post_link( string $format = ‘%link &raquo;’, string $link = ‘%title’, bool $in_same_term = false, int[]|string $excluded_terms = ”, string $taxonomy = ‘category’ )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#user-contributed-notes)

Displays the next post link that is adjacent to the current post.

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

### 󠀁[See also](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#see-also)󠁿

 * [get_next_post_link()](https://developer.wordpress.org/reference/functions/get_next_post_link/)

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

 `$format`stringoptional

Link anchor format. Default ‘%link »’.

Default:`'%link &raquo;'`

`$link`stringoptional

Link permalink format. Default `'%title'`.

Default:`'%title'`

`$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 term IDs.

Default:`''`

`$taxonomy`stringoptional

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

Default:`'category'`

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

    ```php
    function next_post_link( $format = '%link &raquo;', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
    	echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $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.1/src/wp-includes/link-template.php#L2322)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/link-template.php#L2322-L2324)

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

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

Retrieves the next post link that is adjacent to the current post.

  |

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 10 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-4303)
 2.    [Mohammad AbuDayeh](https://profiles.wordpress.org/abudayeh/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-4303)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-4303)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-4303)
 4.  Hola, If you use the Bootstrap, you will encounter a problem in not being able
     to modify the class (a),
 5.  These are in the **single.php** file :
 6.      ```php
         <ul class="pagination justify-content-center mb-4">
         	<ul class="pagination justify-content-center mb-4">
         		<li class="page-item">
         			<?php next_post_link( '%link', '<i class="fas fa-arrow-right"></i> %title' ); ?>
         	        </li>
         	        <li class="page-item">
         		        <?php previous_post_link( '%link', '%title <i class="fas fa-arrow-left"></i>' ); ?>
         	        </li>
         	</ul>
         </ul>
         ```
     
 7.  This is in the **functions.php** file :
 8.      ```php
         function wpdocs_add_post_link( $html ){
         	$html = str_replace( '<a ', '<a class="page-link" ', $html );
         	return $html;
         }
         add_filter( 'next_post_link', 'wpdocs_add_post_link' );
         add_filter( 'previous_post_link', 'wpdocs_add_post_link' );
         ```
     
 9.  I used FontAwesome for the icons that you can change as you like
 10.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D4303%23feedback-editor-4303)
 11.  [Skip to note 11 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-966)
 12.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-966)
 13. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-966)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-966)
 14. **Bold Post Title As Link**
      Displays link with next chronological post’s title
     wrapped in ‘strong’ tags (“**My Next Post Title**”).
 15.     ```php
         <?php next_post_link( '<strong>%link</strong>' ); ?>
         ```
     
 16.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D966%23feedback-editor-966)
 17.  [Skip to note 12 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-968)
 18.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-968)
 19. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-968)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-968)
 20. **Within Same Category, Excluding One**
      Displays link to next post in the same
     category, as long as it is not in category 13 (the category ID #). You can change
     the number to any category you wish to exclude. Exclude multiple categories by
     using ” and ” as a delimiter.
 21.     ```php
         <?php next_post_link( '%link', 'Next post in category', TRUE, '13' ); ?>
         ```
     
 22.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D968%23feedback-editor-968)
 23.  [Skip to note 13 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-969)
 24.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-969)
 25. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-969)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-969)
 26. **Within Same Custom Taxonomy**
      Displays link to next post in the same custom
     taxonomy term.
 27.     ```php
         <?php next_post_link( '%link', 'Next post in taxonomy', TRUE, '', 'my_custom_taxonomy' ); ?>
         ```
     
 28.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D969%23feedback-editor-969)
 29.  [Skip to note 14 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-3744)
 30.   [De’Zsa](https://profiles.wordpress.org/dezsas/)  [  7 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-3744)
 31. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-3744)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-3744)
 32. **Replace Next/Previous Post Text**
 33. Changes the default ‘« %link’ format to just the post title, removing the default
     double arrows.
 34.     ```php
         <?php previous_post_link('%link', '%title'); ?>
         <?php next_post_link('%link', '%title'); ?>
         ```
     
 35. Can replace `%title` with alternative text.
 36.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D3744%23feedback-editor-3744)
 37.  [Skip to note 15 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-970)
 38.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-970)
 39. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-970)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-970)
 40. **Note**
      See [`previous_post_link()`](https://developer.wordpress.org/reference/functions/previous_post_link/).
 41.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D970%23feedback-editor-970)
 42.  [Skip to note 16 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-965)
 43.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-965)
 44. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-965)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-965)
 45. **Example: Default Usage**
      Displays link to the next post (chronologically by
     publish date) with the post title as the link text, followed by a right angle 
     quote (“My Next Post Title »”).
 46.     ```php
         <?php next_post_link(); ?>
         ```
     
 47. If there is no next post, the function does not print anything.
 48.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D965%23feedback-editor-965)
 49.  [Skip to note 17 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-967)
 50.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-967)
 51. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-967)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-967)
 52. **Text As Link, Without Post Title, Within Same Category**
      Displays custom text
     as link to the next post within the same category as the current post. Post title
     is not included here. “Next post in category” is the custom text in this example.
 53.     ```php
         <?php next_post_link( '%link', 'Next post in category', TRUE ); ?>
         ```
     
 54.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D967%23feedback-editor-967)
 55.  [Skip to note 18 content](https://developer.wordpress.org/reference/functions/next_post_link/?output_format=md#comment-content-964)
 56.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/next_post_link/#comment-964)
 57. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-964)
     Vote results for this note: -2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%23comment-964)
 58. **Usage**
 59.     ```php
         <?php next_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ); ?>
         ```
     
 60.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fnext_post_link%2F%3Freplytocom%3D964%23feedback-editor-964)

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