您的问题似乎与此类似:how to limit and display tag?
基于此,您可以使用此代码限制标记:
$post_tags = get_the_tags();
shuffle($post_tags); // use this incase you want to pick the tags randomly
$count = 0;
if ($post_tags) {
foreach($post_tags as $tag) {
$count++;
echo \'<a href="\'.get_tag_link($tag->term_id).\'">\'.$tag->name.\'</a> \';
if( $count > 4 ) break;
}
}
它将只返回3个标签。