Filter hook 'pre_handle_404'

in WP Core File wp-includes/class-wp.php at line 735

View Source

pre_handle_404

Filter Hook
Description
Filters whether to short-circuit default header status handling. Returning a non-false value from the filter will short-circuit the handling and return early.

Hook Information

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

Hook Parameters

Type Name Description
bool $preempt Whether to short-circuit default header status handling. Default false.
WP_Query $wp_query WordPress Query object.

Usage Examples

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

function my_custom_filter($preempt, $wp_query) {
    // Your custom filtering logic here
    return $preempt;
}

Source Code Context

wp-includes/class-wp.php:735 - How this hook is used in WordPress core
<?php
 730  		 * @since 4.5.0
 731  		 *
 732  		 * @param bool     $preempt  Whether to short-circuit default header status handling. Default false.
 733  		 * @param WP_Query $wp_query WordPress Query object.
 734  		 */
 735  		if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) {
 736  			return;
 737  		}
 738  
 739  		// If we've already issued a 404, bail.
 740  		if ( is_404() ) {

PHP Documentation

<?php
/**
		 * Filters whether to short-circuit default header status handling.
		 *
		 * Returning a non-false value from the filter will short-circuit the handling
		 * and return early.
		 *
		 * @since 4.5.0
		 *
		 * @param bool     $preempt  Whether to short-circuit default header status handling. Default false.
		 * @param WP_Query $wp_query WordPress Query object.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/class-wp.php
Related Hooks

Related hooks will be displayed here in future updates.