apply_filters( 'post_link', string $permalink , WP_Post $post , bool $leavename )
Filters the permalink for a post.
Contents
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.
More Information
post_link
is a filter applied to the permalink URL for a post prior to returning the processed url by the function get_permalink() .
This filter only applies to posts with post_type of ‘post’. For that filter which applies to custom post type look post_type_link.
Source
File: wp-includes/link-template.php
.
View all references
return apply_filters( 'post_link', $permalink, $post, $leavename );
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
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
Top ↑
Feedback
There is also
term_link
for archive pages, such as categories. — By nicohood —Used to remove parent category slug from permalinks and maintain subcategories in URL