条件 ACF 分类法和术语未按预期工作(如果 has_term)

问题描述 投票:0回答:0

我为此绞尽脑汁多年,但找不到我想要的解决方案。

在 WordPress 的 archive.php 中,我想要一些条件语句来说明这个 ACF 分类术语是否是这个,然后显示一些内容。

将以下代码放入 PHP 文件中会输出我需要的信息...

<?php 
$terms = get_queried_object();
print_r($terms);
?>

...读作...

WP_Term Object ( [term_id] => 8 [name] => XANN’S VISION [slug] => xanns-vision [term_group] => 0 [term_taxonomy_id] => 8 [taxonomy] => themes [description] => [parent] => 0 [count] => 2 [filter] => raw )

但是当我尝试添加一些条件逻辑时,就像这样......

<?php if ( has_term("XANN'S VISION")) {
echo '<p>hello</p>';
} ?>

...我什么也没得到?任何帮助将不胜感激,谢谢。

wordpress advanced-custom-fields custom-taxonomy
© www.soinside.com 2019 - 2024. All rights reserved.