get_canonical_url
Filter HookDescription
Filters the canonical URL for a post.Hook Information
File Location |
wp-includes/link-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4097 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$canonical_url
|
The post's canonical URL. |
WP_Post
|
$post
|
Post object. |
Usage Examples
Basic Usage
<?php
// Hook into get_canonical_url
add_filter('get_canonical_url', 'my_custom_filter', 10, 2);
function my_custom_filter($canonical_url, $post) {
// Your custom filtering logic here
return $canonical_url;
}
Source Code Context
wp-includes/link-template.php:4097
- How this hook is used in WordPress core
<?php
4092 * @since 4.6.0
4093 *
4094 * @param string $canonical_url The post's canonical URL.
4095 * @param WP_Post $post Post object.
4096 */
4097 return apply_filters( 'get_canonical_url', $canonical_url, $post );
4098 }
4099
4100 /**
4101 * Outputs rel=canonical for singular queries.
4102 *
PHP Documentation
<?php
/**
* Filters the canonical URL for a post.
*
* @since 4.6.0
*
* @param string $canonical_url The post's canonical URL.
* @param WP_Post $post Post object.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/link-template.php
Related Hooks
Related hooks will be displayed here in future updates.