is_404

函数
is_404 ( No parameters )
返回值
  • (bool) Whether the query is a 404 error.
定义位置
相关方法
is_dayis_rtlis_sslis_tagis_tax
引入
1.5.0
弃用
-

is_404: 这个函数用来检查当前请求是否是一个404错误页面。如果请求是一个404错误页面,它返回真,否则返回假。

确定查询的结果是否为404(返回无结果)。

关于这个和类似主题函数的更多信息,请查看《主题开发者手册》中的{@link Conditional Tags}文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_404() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_404();
}
function is_404() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); return false; } return $wp_query->is_404(); }
function is_404() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;
	}

	return $wp_query->is_404();
}

常见问题

FAQs
查看更多 >