{$adjacent}_post_link
Filter HookDescription
Filters the adjacent post link. The dynamic portion of the hook name, `$adjacent`, refers to the type of adjacency, 'next' or 'previous'. Possible hook names include: - `next_post_link` - `previous_post_link`Hook Information
File Location |
wp-includes/link-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2388 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$output
|
The adjacent post link. |
string
|
$format
|
Link anchor format. |
string
|
$link
|
Link permalink format. |
WP_Post|string
|
$post
|
The adjacent post. Empty string if no corresponding post exists. |
string
|
$adjacent
|
Whether the post is previous or next. |
Usage Examples
Basic Usage
<?php
// Hook into {$adjacent}_post_link
add_filter('{$adjacent}_post_link', 'my_custom_filter', 10, 5);
function my_custom_filter($output, $format, $link, $post, $adjacent) {
// Your custom filtering logic here
return $output;
}
Source Code Context
wp-includes/link-template.php:2388
- How this hook is used in WordPress core
<?php
2383 * @param string $format Link anchor format.
2384 * @param string $link Link permalink format.
2385 * @param WP_Post|string $post The adjacent post. Empty string if no corresponding post exists.
2386 * @param string $adjacent Whether the post is previous or next.
2387 */
2388 return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent );
2389 }
2390
2391 /**
2392 * Displays the adjacent post link.
2393 *
PHP Documentation
<?php
/**
* Filters the adjacent post link.
*
* The dynamic portion of the hook name, `$adjacent`, refers to the type
* of adjacency, 'next' or 'previous'.
*
* Possible hook names include:
*
* - `next_post_link`
* - `previous_post_link`
*
* @since 2.6.0
* @since 4.2.0 Added the `$adjacent` parameter.
*
* @param string $output The adjacent post link.
* @param string $format Link anchor format.
* @param string $link Link permalink format.
* @param WP_Post|string $post The adjacent post. Empty string if no corresponding post exists.
* @param string $adjacent Whether the post is previous or next.
*/
Quick Info
- Hook Type: Filter
- Parameters: 5
- File: wp-includes/link-template.php
Related Hooks
Related hooks will be displayed here in future updates.