我有这段代码来显示循环外的特定帖子的内容(实际上在archive.php模板文件中)。如何包含标签?
<?php
$my_id = 1576;
$post_id_1576= get_post($my_id);
$content = $post_id_1576->post_content;
$content = apply_filters(\'the_content\', $content);
$content = str_replace(\']]>\', \']]>\', $content);
echo $content;
?>
最合适的回答,由SO网友:Gregory 整理而成
简单使用get_the_tags($my_id)
, 示例:
$posttags = get_the_tags($my_id);
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . \' \';
}
}
参考
WordPress codex