我有2个分类集product_cat和tvshows_cat.每套有12个术语.
一个产品最多可以有12个术语(但不能同时使用2个).
我使用此代码在产品页面中显示术语列表:
$cats = get_the_term_list($post->ID, 'product_cat', '', ' ', '');
$tvcats = get_the_term_list($post->ID, 'tvshows_cat', '', ' ', '');
if (!empty($cats)){
echo strip_tags($cats, ' ');
}elseif(!empty($tvcats)){
echo strip_tags($tvcats, ' ');
}
Run Code Online (Sandbox Code Playgroud)
结果是:
动作,戏剧,冒险,传记,动画
问题是,在某些情况下,没有足够的空间来显示所有术语.
我需要将条款数量限制为2个条款.
题:
如何限制应用于两个的术语数量?
谢谢