is_post_type_archive()
is_post_type_archive( string|string[] $post_types = ” )…
is_post_type_archive( string|string[] $post_types = ” )
确定查询是否针对现有的post-type存档页。
Determines whether the query is for an existing post type archive page.
确定查询是否针对现有的post-type存档页。
Determines whether the query is for an existing post type archive page.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
有关此主题函数和类似主题函数的更多信息,请参阅主题开发人员手册中的条件标记文章。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $post_types | (string | string[]) | 可选 | 要检查的Post类型或Post类型数组。 |
返回(Return)
(bool)
源码(Source)
/**
* Is the query for an existing post type archive page?
*
* @since 3.1.0
*
* @global WP_Query $wp_query
*
* @param string|array $post_types Optional. Post type or array of posts types to check against.
* @return bool
*/
function is_post_type_archive( $post_types = '' ) {
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' );
return false;
}
return $wp_query->is_post_type_archive( $post_types );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.1.0 | wp-includes/query.php:179 | 9 | 3 |
笔记(Notes)
例子
用法
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!