您的当前位置:首页 > 知识博客 > wordpress建站

WordPress判断是否为标签函数:is_tag

时间:2024-03-14

WordPress函数is_tag用于判断是否标签,通常用在归档页archive.php或分类页category.php,以便为分类和标签输出不同的内容。

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

函数参数

$tag

整数,字符串或数组

提供标签的ID、名称或别名

函数使用示例

下面是在归档页中的使用示例,在归档页和分类页中,全局变量$cat为分类或标签的ID:

if(is_tag($cat)) {
	include 'tag.php';
} else {
	include 'cat.php';
}

扩展阅读

is_tag()函数位于:wp-includes/query.php

相关函数:

  • is_category()

  • is_archive()

  • is_tax()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 java.fit


Whatsapp
Powered by RRZCMS