previous_post_link filter-hookWP 2.6.0

Filters the adjacent post link.

This is one of the variants of the dynamic hook (adjacent)_post_link

Usage

add_filter( 'previous_post_link', 'wp_kama_previous_post_link_filter', 10, 5 );

/**
 * Function for `previous_post_link` filter-hook.
 * 
 * @param string  $output   The adjacent post link.
 * @param string  $format   Link anchor format.
 * @param string  $link     Link permalink format.
 * @param WP_Post $post     The adjacent post.
 * @param string  $adjacent Whether the post is previous or next.
 *
 * @return string
 */
function wp_kama_previous_post_link_filter( $output, $format, $link, $post, $adjacent ){

	// filter...
	return $output;
}
$output(string)
The adjacent post link.
$format(string)
Link anchor format.
$link(string)
Link permalink format.
$post(WP_Post)
The adjacent post.
$adjacent(string)
Whether the post is previous or next.

Changelog

Since 2.6.0 Introduced.
Since 4.2.0 Added the $adjacent parameter.

Where the hook is called

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

Where the hook is used in WordPress

Usage not found.