pre_handle_404 filter-hookWP 4.5.0

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.

Usage

add_filter( 'pre_handle_404', 'wp_kama_pre_handle_404_filter', 10, 2 );

/**
 * Function for `pre_handle_404` filter-hook.
 * 
 * @param bool     $preempt  Whether to short-circuit default header status handling.
 * @param WP_Query $wp_query WordPress Query object.
 *
 * @return bool
 */
function wp_kama_pre_handle_404_filter( $preempt, $wp_query ){

	// filter...
	return $preempt;
}
$preempt(true|false)
Whether to short-circuit default header status handling.
Default: false
$wp_query(WP_Query)
WordPress Query object.

Changelog

Since 4.5.0 Introduced.

Where the hook is called

WP::handle_404()
pre_handle_404
wp-includes/class-wp.php 730
if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) {

Where the hook is used in WordPress

wp-includes/sitemaps/class-wp-sitemaps.php 78
add_filter( 'pre_handle_404', array( $this, 'redirect_sitemapxml' ), 10, 2 );