当前浏览:首页 / WordPress函数 / is_tag()

is_tag( int|string|int[]|string[] $tag = '' )

是否为现有的标签存档页

is 条件判断more...

tagmore...


描述

如果指定了$tag参数,此函数还将检查查询是否针对指定的标签之一。

更多类似的主题函数信息,请查看主题开发手册中的条件标签文章。


参数

$tag

(int|string|int[]|string[]) (可选) 要检查的标签ID、name、slug或其数组。

默认值: ''


返回

(bool) 查询是否针对现有标签存档页。



源码

查看源码 官方文档


更新日志

版本描述
2.3.0开始引入

使用示例

  • 示例1

    示例

    // When any Tag archive page is being displayed.
    is_tag();
    
    // When the archive page for Tag 30 is being displayed.
    is_tag( '30' );
    
    // When the archive page for tag with the Slug of 'extreme' is being displayed.
    is_tag( 'extreme' );
    
    // When the archive page for tag with the Name of 'mild' is being displayed.
    is_tag( 'mild' );
    
    /*
     * Returns true when the tag of posts being displayed is either term_ID 30,
     * or slug "extreme", or name "mild". Note: the array ability was added
     * at Version 3.7.
     */
    is_tag( array( 30, 'mild', 'extreme' ) );