post_link
Filters the permalink for a post.
Only applies to posts with post_type of 'post'.
Usage
add_filter( 'post_link', 'wp_kama_post_link_filter', 10, 3 );
/**
* Function for `post_link` filter-hook.
*
* @param string $permalink The post's permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*
* @return string
*/
function wp_kama_post_link_filter( $permalink, $post, $leavename ){
// filter...
return $permalink;
}
- $permalink(string)
- The post's permalink.
- $post(WP_Post)
- The post in question.
- $leavename(true|false)
- Whether to keep the post name.
Changelog
| Since 1.5.0 | Introduced. |
Where the hook is called
wp-includes/link-template.php 308
return apply_filters( 'post_link', $permalink, $post, $leavename );