[英]Wordpress - List out tags on template files
如何將所有標簽列出到模板文件中?
我查看了wordpress文檔並找到了它。
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ' ';
}
}
?>
但是,這不會輸出任何內容到我的模板。
我需要在模板上缺少某些東西嗎?
試試這個代碼
<?php
$posttags = get_terms( array( 'taxonomy' => 'post_tag') );
if ($posttags ) {
foreach($posttags as $tag) {
echo $tag->name . ' ';
}
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.