我只有在有标签的情况下才会显示标签,并且在标签中也包含php。这是我尝试过的,但什么都没有表现出来。
<?php
if( has_tag() ) { ?>
<!-- Start of tags -->
<?php echo get_the_term_list( $post->ID, \'download_tag\', \'Tags \', \', \', \'\' ); ?>
<!-- End of tags -->
<?php
}
?>
我只有在有标签的情况下才会显示标签,并且在标签中也包含php。这是我尝试过的,但什么都没有表现出来。
<?php
if( has_tag() ) { ?>
<!-- Start of tags -->
<?php echo get_the_term_list( $post->ID, \'download_tag\', \'Tags \', \', \', \'\' ); ?>
<!-- End of tags -->
<?php
}
?>
has\\u tag函数没有达到您在这里所期望的效果。它实际上意味着“post has tag”检查一篇文章(或当前文章)是否有特定的标记。类似于has_tag( \'self-important-tag\' )
. See the codex
如果您省略了条件,并且帖子没有标记,get\\u\\u termlist将不回显任何内容,因为它会检查帖子内部是否有术语:
<!-- Start of tags -->
<?php echo get_the_term_list( $post->ID, \'download_tag\', \'Tags \', \', \', \'\' ); ?>
<!-- End of tags -->
在您的条件下,尝试以下方法:
<?php
$var = get_the_term_list( $post->ID, \'download_tag\', \'Tags \', \', \', \'\' );
echo $var;
?>
[我没有测试过!]我有一个项目的标签覆盖,我想显示他们像一个列表,而不是一个昏迷像它出现在下面的附件。代码如下:<p class=\"nom\"> <?php echo strip_tags (get_the_term_list( get_the_ID(), \'project_tag\', \'\',\', \')); ?></p> 有什么想法吗?我已经尝试插入<br> 但它不起作用。。。谢谢哦!更新,以下是所有代码: if ( \'\' !==