WordPress获取Tag信息函数:get_the_tags
WordPress模板函数get_the_tags用于获取函数信息,包括函数ID、别名、名称、描述等。get_…
WordPress模板函数get_the_tags用于获取函数信息,包括函数ID、别名、名称、描述等。get_the_tags()函数需要用在The Loop主循环中,如果在主循环之外使用,需要传递文章ID。
get_the_tags( int $id = 0 )
函数参数
$id
整数型,默认值:当前文章ID
指定文章ID,将返回该文章的函数信息。
函数返回值
Array ( [0] => WP_Term Object ( [term_id] => 27 [name] => CDN [slug] => cdn [term_group] => 0 [term_taxonomy_id] => 27 [taxonomy] => post_tag [description] => CDN的全称是Content Delivery Network,即内容分发网络。 [parent] => 0 [count] => 11 [filter] => raw ) )
函数使用示例
<?php
	$posttags = get_the_tags();
	if ($posttags) {
	  foreach($posttags as $tag) {
		echo '函数ID:' . $tag->term_id;
		echo '<br />函数名称:' . $tag->name;
		echo '<br />函数描述:' . $tag->description;
	  }
	}
?>扩展阅读
get_the_tags()函数位于:wp-includes/category-template.php
相关函数:
- get_tag()
 - get_tag_link()
 - get_tags()
 - get_the_tag_list()
 - is_tag()
 - the_tags()
 - single_tag_title()
 - tag_description()
 - wp_generate_tag_cloud()
 - wp_tag_cloud()
 
类别:WordPress函数讲解、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!