2016-08-19 11 views
0

如何列出所有标签到模板文件?WordPress的 - 列出模板文件上的标签

我已经看过了WordPress的文档,发现这个..

<?php 
    $posttags = get_the_tags(); 
    if ($posttags) { 
     foreach($posttags as $tag) { 
      echo $tag->name . ' '; 
     } 
    } 
?> 

尽管如此,这并不输出任何东西到我的模板。

有什么,我想念我需要做的模板?

+0

是为'的var_dump输出($ posttags)'或你成为任何错误? – Provie9

回答

1

试试这个代码

<?php 
    $posttags = get_terms(array( 'taxonomy' => 'post_tag')); 

    if ($posttags) { 
     foreach($posttags as $tag) { 
      echo $tag->name . ' '; 
     } 
    } 
?> 
+0

Vel这个作品非常感谢你。 –

+0

欢迎你@MaxLynn – vel