pre_post_link
Filter HookDescription
Filters the permalink structure for a post before token replacement occurs. 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 | 217 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$permalink
|
The site's permalink structure. |
WP_Post
|
$post
|
The post in question. |
bool
|
$leavename
|
Whether to keep the post name. |
Usage Examples
Basic Usage
<?php
// Hook into pre_post_link
add_filter('pre_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:217
- How this hook is used in WordPress core
<?php
212 *
213 * @param string $permalink The site's permalink structure.
214 * @param WP_Post $post The post in question.
215 * @param bool $leavename Whether to keep the post name.
216 */
217 $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
218
219 if (
220 $permalink &&
221 ! wp_force_plain_post_permalink( $post )
222 ) {
PHP Documentation
<?php
/**
* Filters the permalink structure for a post before token replacement occurs.
*
* Only applies to posts with post_type of 'post'.
*
* @since 3.0.0
*
* @param string $permalink The site's permalink structure.
* @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.