【发布时间】:2017-01-11 20:41:06
【问题描述】:
我有 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, ' ');
}
结果是:
动作、剧情、冒险、传记、动画
问题在于,在某些情况下,没有足够的空间来显示所有术语。
我需要将术语数量限制为 2 个术语。
问题:
我怎样才能限制适用于两个术语的数量?
谢谢
【问题讨论】:
标签: php wordpress woocommerce categories custom-taxonomy