get_the_tags()函數(shù)用于獲取標簽信息,包括標簽ID、別名、名稱、描述等。get_the_tags()函數(shù)需要用在The Loop主循環(huán)中,如果在主循環(huán)之外使用,需要傳遞文章ID。
語法
get_the_tags( int $id = 0 )
參數(shù)
實例
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo '標簽ID:' . $tag->term_id;
echo '<br />標簽名稱:' . $tag->name;
echo '<br />標簽描述:' . $tag->description;
}
}
?>