【问题标题】:Display an image before each tag in Wordpress在 Wordpress 中的每个标签之前显示图像
【发布时间】:2013-11-05 12:22:49
【问题描述】:

我使用自定义分类法制作了自定义帖子。我现在正在尝试在每个自定义标签前显示图像。

使用下面的代码,我只能在第一个标签前看到一张图片。我希望图像显示在每个标签之前。

<?php the_terms( $post->ID, 'case_tags', '<img src="theimage" />','<br /> '); ?></div><!--end .case-tags -->

这可能吗?

【问题讨论】:

    标签: php image wordpress tags taxonomy


    【解决方案1】:

    the_terms 函数的文档-

    <?php the_terms( $id, $taxonomy, $before, $sep, $after ); ?> 
    

    看起来您提供的图像作为之前的参数,所以它只被打印一次。尝试将图像放入两次,以便为 before 和 separation 参数打印。

    <?php the_terms( $post->ID, 'case_tags', '<img src="theimage" />', '<img src="theimage" />','<br /> '); ?></div><!--end .case-tags -->
    

    【讨论】:

    • 谢谢你成功了。起初我的换行符搞砸了,但我修好了。
    • 发布解决方案代码以防其他人遇到同样的问题。 ID, 'case_tags', '','
      ',' '); ?>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多