WP_Query::is_post_type_archive()
Determines whether the query is for an existing post type archive page.
Метод класса: WP_Query{}
Хуков нет.
Возвращает
true|false
. Whether the query is for an existing post type archive page.
Использование
global $wp_query; $wp_query->is_post_type_archive( $post_types );
- $post_types(строка|string[])
- Post type or array of posts types to check against.
По умолчанию: ''
Список изменений
С версии 3.1.0 | Введена. |
Код WP_Query::is_post_type_archive() WP Query::is post type archive WP 6.7.1
public function is_post_type_archive( $post_types = '' ) { if ( empty( $post_types ) || ! $this->is_post_type_archive ) { return (bool) $this->is_post_type_archive; } $post_type = $this->get( 'post_type' ); if ( is_array( $post_type ) ) { $post_type = reset( $post_type ); } $post_type_object = get_post_type_object( $post_type ); if ( ! $post_type_object ) { return false; } return in_array( $post_type_object->name, (array) $post_types, true ); }