is_404() 和is_page() 只是检查条件是否存在的条件。喜欢is_404() 只需检查当前页面是否为404页面,并在成功时返回true,在失败时返回false。
非常重要的注意事项:在运行查询之前,条件查询标记不起作用。在此之前,它们总是返回false
只需执行var_dump 在…上get_queried_object() 比如说
 <?php
 $queried_object = get_queried_object();
 var_dump( $queried_object );
 ?>
EDIT
所有这些条件都是在
WP_Query 类,然后分别包装在
wp-includes/query.php. 例如,
is_404() 只是一个包装
$wp_query->is_404();697 /**
698  * Is the query a 404 (returns no results)?
699  *
700  * @see WP_Query::is_404()
701  * @since 1.5.0
702  * @uses $wp_query
703  *
704  * @return bool
705  */
706 function is_404() {
707         global $wp_query;
708 
709         if ( ! isset( $wp_query ) ) {
710                 _doing_it_wrong( __FUNCTION__, __( \'Conditional query tags do not work before the query is run. Before then, they always return false.\' ), \'3.1\' );
711                 return false;
712         }
713 
714         return $wp_query->is_404();
715 }