2011-01-25 3 views
1

投稿タグからのタグテキストのみを出力するスクリプトが必要です。リンクやulなどのものではなく、単純なテキストなので、このテキストを投稿のクラスとして追加することができます。 誰でも助けることができますか? ありがとうございました!ここに答え設立Wordpress - get_the_tag_list - テキストのみ!

答えて

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');} ' –

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を参照してください。

関連する問題