the_permalink
Filter HookDescription
Filters the display of the permalink for the current post.Hook Information
File Location |
wp-includes/link-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 27 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$permalink
|
The permalink for the current post. |
int|WP_Post
|
$post
|
Post ID, WP_Post object, or 0. Default 0. |
Usage Examples
Basic Usage
<?php
// Hook into the_permalink
add_filter('the_permalink', 'my_custom_filter', 10, 2);
function my_custom_filter($permalink, $post) {
// Your custom filtering logic here
return $permalink;
}
Source Code Context
wp-includes/link-template.php:27
- How this hook is used in WordPress core
<?php
22 * @since 4.4.0 Added the `$post` parameter.
23 *
24 * @param string $permalink The permalink for the current post.
25 * @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0.
26 */
27 echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );
28 }
29
30 /**
31 * Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
32 *
PHP Documentation
<?php
/**
* Filters the display of the permalink for the current post.
*
* @since 1.5.0
* @since 4.4.0 Added the `$post` parameter.
*
* @param string $permalink The permalink for the current post.
* @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/link-template.php
Related Hooks
Related hooks will be displayed here in future updates.