WordPress,如何从帖子页面中的标签名称获取标签标签?

在单个帖子中, 如何获取用于该特定帖子的标签slug和标签ID。

例如我有一个帖子” Hello World!”在”我的帖子”中标记。如何在” Hello World!”中获得”我的帖子”。发布页面(即single.php文件)。


#1


$terms = get_the_terms( $post->ID, 'post_tag' );
if ( !empty( $terms ) ){
    // get the first term
    $term = array_shift( $terms );
    echo $term->slug;
}

参考:https://wordpress.stackexchange.com/questions/130947/get-term-slug-of-current-post

来源:

https://www.srcmini02.com/67666.html

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?