strict_redirect_guess_404_permalink
Filter HookDescription
Filters whether to perform a strict guess for a 404 redirect. Returning a truthy value from the filter will redirect only exact post_name matches.Hook Information
File Location |
wp-includes/canonical.php
View on GitHub
|
Hook Type | Filter |
Line Number | 965 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$strict_guess
|
Whether to perform a strict guess. Default false (loose guess). |
Usage Examples
Basic Usage
<?php
// Hook into strict_redirect_guess_404_permalink
add_filter('strict_redirect_guess_404_permalink', 'my_custom_filter', 10, 1);
function my_custom_filter($strict_guess) {
// Your custom filtering logic here
return $strict_guess;
}
Source Code Context
wp-includes/canonical.php:965
- How this hook is used in WordPress core
<?php
960 *
961 * @since 5.5.0
962 *
963 * @param bool $strict_guess Whether to perform a strict guess. Default false (loose guess).
964 */
965 $strict_guess = apply_filters( 'strict_redirect_guess_404_permalink', false );
966
967 if ( $strict_guess ) {
968 $where = $wpdb->prepare( 'post_name = %s', get_query_var( 'name' ) );
969 } else {
970 $where = $wpdb->prepare( 'post_name LIKE %s', $wpdb->esc_like( get_query_var( 'name' ) ) . '%' );
PHP Documentation
<?php
/**
* Filters whether to perform a strict guess for a 404 redirect.
*
* Returning a truthy value from the filter will redirect only exact post_name matches.
*
* @since 5.5.0
*
* @param bool $strict_guess Whether to perform a strict guess. Default false (loose guess).
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/canonical.php
Related Hooks
Related hooks will be displayed here in future updates.