<adjacent>_post_link

Filters the adjacent post link.

Description

apply_filters( '<adjacent>_post_link', (string) $output, (string) $format, (string) $link, (WP_Post) $post, (string) $adjacent ); 

The dynamic portion(s) of the hook name refer to the type of adjacency, next or previous..

Parameters (5)

0. $output (string)
The adjacent post link.
1. $format (string)
Link anchor format.
2. $link (string)
Link permalink format.
3. $post (WP_Post)
The adjacent post.
4. $adjacent (string)
Whether the post is previous or next.

Usage

To run the hook, copy the example below.
  1. $output = apply_filters( '{$adjacent}_post_link', $output, $format, $link, $post, $adjacent ); 
  2.  
  3. if ( !empty( $output ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the <adjacent>_post_link callback 
  2. function filter_adjacent_post_link( $output, $format, $link, $post, $adjacent ) { 
  3. // make filter magic happen here... 
  4. return $output
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "{$adjacent}_post_link", 'filter_adjacent_post_link', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "{$adjacent}_post_link", 'filter_adjacent_post_link', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/link-template.php  
  1. return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent );