redirect_canonical WordPress Filter Hook

The redirect_canonical hook is used to redirect a visitor to the correct URL for a given page. This is useful for pages that have multiple URLs, such as when the www version of a URL is different from the non-www version. This hook is also useful for pages that are accessed through multiple URL schemes, such as http and https. By redirecting the visitor to the correct URL, you can ensure that they always access the page through the correct scheme.

apply_filters( 'redirect_canonical', string $redirect_url, string $requested_url ) #

Filters the canonical redirect URL.


Description

Returning false to this filter will cancel the redirect.


Top ↑

Parameters

$redirect_url

(string)The redirect URL.

$requested_url

(string)The requested URL.


Top ↑

Source

File: wp-includes/canonical.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.