Filters the permalink for a post.
Description
Only applies to posts with post_type of ‘post’.
Parameters
$permalink
string- The post’s permalink.
$post
WP_Post- The post in question.
$leavename
bool- 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_link
attachment_link
post_type_link
term_link
for archive pages, such as categories.Used to remove parent category slug from permalinks and maintain subcategories in URL