is_post_type_archive()

最后更新于:2021-11-27 10:11:05

is_post_type_archive( string|string[]$post_types=”)

Determines whether the query is for an existing post type archive page.

参数

$post_types

(string|string[]) (Optional) Post type or array of posts types to check against.

Default value: ”

响应

(bool) Whether the query is for an existing post type archive page.

源文件

文件: gc-includes/query.php

function is_post_type_archive( $post_types = '' ) {
	global $gc_query;

	if ( ! isset( $gc_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 $gc_query->is_post_type_archive( $post_types );
}