redirect_canonical
Filter HookDescription
Filters the canonical redirect URL. Returning false to this filter will cancel the redirect.Hook Information
File Location |
wp-includes/canonical.php
View on GitHub
|
Hook Type | Filter |
Line Number | 821 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$redirect_url
|
The redirect URL. |
string
|
$requested_url
|
The requested URL. |
Usage Examples
Basic Usage
<?php
// Hook into redirect_canonical
add_filter('redirect_canonical', 'my_custom_filter', 10, 2);
function my_custom_filter($redirect_url, $requested_url) {
// Your custom filtering logic here
return $redirect_url;
}
Source Code Context
wp-includes/canonical.php:821
- How this hook is used in WordPress core
<?php
816 * @since 2.3.0
817 *
818 * @param string $redirect_url The redirect URL.
819 * @param string $requested_url The requested URL.
820 */
821 $redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url );
822
823 // Yes, again -- in case the filter aborted the request.
824 if ( ! $redirect_url || strip_fragment_from_url( $redirect_url ) === strip_fragment_from_url( $requested_url ) ) {
825 return;
826 }
PHP Documentation
<?php
/**
* Filters the canonical redirect URL.
*
* Returning false to this filter will cancel the redirect.
*
* @since 2.3.0
*
* @param string $redirect_url The redirect URL.
* @param string $requested_url The requested URL.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/canonical.php
Related Hooks
Related hooks will be displayed here in future updates.