Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
is_tag() - 是否为现有的标签存档页 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / is_tag()

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

是否为现有的标签存档页


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 2 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "c36259426466be41cc8d1020291d7414" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "a935db3d255e17450f4b387b9565b626" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

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' ) );