Uses
Uses | Description |
---|---|
wp-includes/class-wp-query.php: WP_Query::get() | Retrieve query variable. |
wp-includes/post.php: get_post_type_object() | Retrieves a post type object by name. |
Is the query for an existing post type archive page?
(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.
File: wp-includes/class-wp-query.php
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 ); return in_array( $post_type_object->name, (array) $post_types, true ); }
Version | Description |
---|---|
3.1.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_query/is_post_type_archive