Filter hook 'pre_redirect_guess_404_permalink'

in WP Core File wp-includes/canonical.php at line 947

View Source

pre_redirect_guess_404_permalink

Filter Hook
Description
Short-circuits the redirect URL guessing for 404 requests. Returning a non-null value from the filter will effectively short-circuit the URL guessing, returning the passed value instead.

Hook Information

File Location wp-includes/canonical.php View on GitHub
Hook Type Filter
Line Number 947

Hook Parameters

Type Name Description
null|string|false $pre Whether to short-circuit guessing the redirect for a 404. Default null to continue with the URL guessing.

Usage Examples

Basic Usage
<?php
// Hook into pre_redirect_guess_404_permalink
add_filter('pre_redirect_guess_404_permalink', 'my_custom_filter', 10, 1);

function my_custom_filter($pre) {
    // Your custom filtering logic here
    return $pre;
}

Source Code Context

wp-includes/canonical.php:947 - How this hook is used in WordPress core
<?php
 942  	 * @since 5.5.0
 943  	 *
 944  	 * @param null|string|false $pre Whether to short-circuit guessing the redirect for a 404.
 945  	 *                               Default null to continue with the URL guessing.
 946  	 */
 947  	$pre = apply_filters( 'pre_redirect_guess_404_permalink', null );
 948  	if ( null !== $pre ) {
 949  		return $pre;
 950  	}
 951  
 952  	if ( get_query_var( 'name' ) ) {

PHP Documentation

<?php
/**
	 * Short-circuits the redirect URL guessing for 404 requests.
	 *
	 * Returning a non-null value from the filter will effectively short-circuit
	 * the URL guessing, returning the passed value instead.
	 *
	 * @since 5.5.0
	 *
	 * @param null|string|false $pre Whether to short-circuit guessing the redirect for a 404.
	 *                               Default null to continue with the URL guessing.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/canonical.php
Related Hooks

Related hooks will be displayed here in future updates.