Beispiel #1
0
<?php

$terms = get_the_terms($post, 'products');
if (!$terms) {
    return;
}
$opts = array('short' => true);
$groups = group_terms($terms, $opts);
$terms = array();
foreach ($groups as $group_term_id => $group_terms) {
    if ($group_terms[$group_term_id] || count($group_terms) > 3) {
        $group_name = get_term($group_term_id, 'products')->name;
        $terms[$group_term_id] = $group_name;
    } else {
        $terms += $group_terms;
    }
}
?>

<dt><?php 
echo has_term('Restaurant', 'business-type') ? __('Local Ingredients') : (has_term('Retailer', 'business-type') ? __('Local Products') : __('Products'));
?>
</dt>
<dd><?php 
echo format_products($terms);
?>
</dd>
Beispiel #2
0
<?php

$terms = get_the_terms($post, 'products');
if (!$terms) {
    return;
}
$groups = group_terms($terms);
if (count($groups) == 1) {
    $terms = current($groups);
    $groups = array();
} else {
    $terms = array();
    foreach ($groups as $group_term_id => $group_terms) {
        if (count($group_terms) <= ($group_terms[$group_term_id] ? 4 : 3)) {
            $terms[current($group_terms)] = $group_terms;
        }
    }
    if (count($terms) > 1) {
        ksort($terms);
        $terms = my_array_sum($terms);
        foreach ($groups as $group_term_id => $group_terms) {
            if (count($group_terms) <= ($group_terms[$group_term_id] ? 4 : 3)) {
                unset($groups[$group_term_id]);
            }
        }
    } else {
        $terms = current($terms);
        if (count($terms) == 1 && $groups[key($terms)]) {
            unset($groups[key($terms)]);
        } else {
            $terms = false;