get_term_link()函数

自定义类型的分类是无法用 <?php echo get_category_link( $category_id ); ?> 输出分类链接地址的,需要用 get_term_link() 函数

语法结构

get_term_link( object|int|string $term, string $taxonomy )

参数

$taxonomy自定义分类的名称

实例

<?php
//根据别名redian获取其对应的分类id
$term=get_term_by(‘slug’,’theme’,’products’);
$term_id=$term->term_id;
//根据id获取分类对应链接
$link=get_term_link($term_id,’products’);
echo $link;
?>

  • 3554稳定运行(天)
  • 1会员总数(位)
  • 28195资源总数(个)
  • 0 本周更新(个)
  • 0今日发布(个)

目前已经有 1 位会员加入