Typecho

typecho 获取文章标签缩略名

by Intern, 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); ?>

Intern

作者: Intern

2021 © typecho & elise