确定查询是否针对现有自定义分类存档页面。
原型
is_tax( string|array $taxonomy = '', int|string|array $term = '' )
描述
如果指定了$ taxonomy参数,则此函数将另外检查查询是否针对该特定$ taxonomy。
参数
$taxonomy
(string|array)
(Optional)
分类学slu or或slu ..
$term
(int|string|array)
(Optional)
术语ID,名称,段塞或术语ID,名称和段塞数组。
返回值
(bool)
对于自定义分类存档页面为True,对于内置分类法(类别和标记存档)为false。
源文件
路径:wp-includes/query.php
<?php
...
function is_tax( $taxonomy = '', $term = '' ) {
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.0' );
return false;
}
return $wp_query->is_tax( $taxonomy, $term );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/is_tax/