post_link
Filter HookDescription
Filters the permalink for a post. Only applies to posts with post_type of 'post'.Hook Information
File Location |
wp-includes/link-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 308 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$permalink
|
The post's permalink. |
WP_Post
|
$post
|
The post in question. |
bool
|
$leavename
|
Whether to keep the post name. |
Usage Examples
Basic Usage
<?php
// Hook into post_link
add_filter('post_link', 'my_custom_filter', 10, 3);
function my_custom_filter($permalink, $post, $leavename) {
// Your custom filtering logic here
return $permalink;
}
Source Code Context
wp-includes/link-template.php:308
- How this hook is used in WordPress core
<?php
303 *
304 * @param string $permalink The post's permalink.
305 * @param WP_Post $post The post in question.
306 * @param bool $leavename Whether to keep the post name.
307 */
308 return apply_filters( 'post_link', $permalink, $post, $leavename );
309 }
310
311 /**
312 * Retrieves the permalink for a post of a custom post type.
313 *
PHP Documentation
<?php
/**
* Filters the permalink for a post.
*
* Only applies to posts with post_type of 'post'.
*
* @since 1.5.0
*
* @param string $permalink The post's permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/link-template.php
Related Hooks
Related hooks will be displayed here in future updates.