2011-01-25 20 views

回答

1

成立這裏的答案: need help in using get_the_tag_list($ID) WordPress

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

這對[wp_list_pluck]很有用(https://codex.wordpress.org/Function_Reference/wp_list_pluck): `$ posttags = get_the_tags(); if($ posttags){echo implode('',wp_list_pluck($ posttags,'name');}` – 2016-05-03 17:32:30

0

我需要爲我的元數據標籤列表,這裏就是我組裝的字符串:

echo implode(',', array_map(function($tag){ 
    return $tag->name; 
}, get_the_tags())); 

這導致以逗號分隔標籤列表可以在元標記中使用。您可以刪除逗號或球場

-1

您可以使用get_the_tag_list方法列出標籤。

<?php echo strip_tags(get_the_tag_list('',' , ','')); ?> 

有關更多詳細信息,請參閱WordPress Codex docs