检查get_queried_object()
.
在类别的存档上Uncategorized
你会得到像…
stdClass Object
(
[term_id] => 1
[name] => Uncategorized
[slug] => uncategorized
[term_group] => 0
[term_taxonomy_id] => 1
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 8
[cat_ID] => 1
[category_count] => 8
[category_description] =>
[cat_name] => Uncategorized
[category_nicename] => uncategorized
[category_parent] => 0
)
…并保存在标签的存档中
test
…
stdClass Object
(
[term_id] => 18
[name] => test
[slug] => test-2
[term_group] => 0
[term_taxonomy_id] => 18
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 1
)
因此,您可以测试属性
taxonomy
因为该对象存在,其值是什么。然后调整模板。