WordPress at a glance
function is not described

WP_Query::set_404() public WP 2.0.0

Sets the 404 property and saves whether query is feed.

{} It's a method of the class: WP_Query{}

Hooks from the method
Return

null. Nothing.

Usage

global $wp_query;
$wp_query->set_404();

Changelog

Since 2.0.0 Introduced.

Code of WP_Query::set_404() WP 5.7.2

<?php
public function set_404() {
	$is_feed = $this->is_feed;

	$this->init_query_flags();
	$this->is_404 = true;

	$this->is_feed = $is_feed;

	/**
	 * Fires after a 404 is triggered.
	 *
	 * @since 5.5.0
	 *
	 * @param WP_Query $query The WP_Query instance (passed by reference).
	 */
	do_action_ref_array( 'set_404', array( $this ) );
}