在单个帖子中, 如何获取用于该特定帖子的标签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
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_39951.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57