在商店类别列表中显示更多选项

时间:2017-05-10 14:14:43

标签: php foreach

如何在存档列表页面上仅显示6个类别,如果选择的选项超过6个,则显示更多的按钮?

<?php
$terms = get_the_terms($post->ID, 'store_categories');
if ($terms && !is_wp_error($terms)):
    $store = array();
    foreach ($terms as $term) {
        $store[] = $term->name;
    }
    $store_category = join(" | ", $store);
?>
      <h3 id="storeCat">
            <?php
    $url = site_url();
    foreach ($terms as $term) {
        $linklist .= "<a href='" . $url . "/store_categories/" . $term->slug . "' target='_blank'>" . $term->name . "</a>" . "&nbsp; ";
    }
        echo $linklist;
?>
      </h3>
        <?php
endif;
?>

0 个答案:

没有答案