Filters the permalink for a post.
Description
Only applies to posts with post_type of ‘post’.
Parameters
$permalinkstring- The post’s permalink.
$postWP_Post- The post in question.
$leavenamebool- Whether to keep the post name.
Source
return apply_filters( 'post_link', $permalink, $post, $leavename );
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
Example migrated from Codex:
Append the query string for posts to permalink URLs (uses add_query_arg):
For other post types, use the following filters:
page_linkattachment_linkpost_type_linkterm_linkfor archive pages, such as categories.Used to remove parent category slug from permalinks and maintain subcategories in URL