可说欢喜
Typecho

typecho 获取文章标签缩略名

by 温柔, 2021-04-12


将下面代码放入functions.php适当位置


function tagsslug($widget, $split = ' ', $default = NULL)
{

if ($widget->tags) {
 
$result = array();
foreach ($widget->tags as $tag) {
$result[] = $tag['slug'];
}
 
return implode($split, $result);
} else {
return $default;
}
}

输出文章标签缩略名 <?php echo tagsslug($this); ?>

function tagsname($widget, $split = ' ', $default = NULL)
{

if ($widget->tags) {
 
$result = array();
foreach ($widget->tags as $tag) {
$result[] = $tag['name'];
}
 
return implode($split, $result);
} else {
return $default;
}
}

输出文章标签名 <?php echo tagsname($this); ?>

typechoslugtags
温柔

作者: 温柔

2024 © typecho & elise