protected function print_category($cat, $sep = '') { $term_meta = get_option('ipt_kb_category_meta_' . $cat->term_id, array()); echo '<a href="' . esc_url(get_category_link($cat->term_id)) . '" class="list-group-item' . (is_category($cat->term_id) || is_single() && has_category($cat->term_id) ? ' active' : '') . '">'; echo '<span class="badge">' . ipt_kb_total_cat_post_count($cat->term_id) . '</span>'; echo $sep; $icon_class = 'ipt-books'; if (isset($term_meta['icon_class']) && trim($term_meta['icon_class']) != '') { $icon_class = $term_meta['icon_class']; } echo '<span class="glyphicon ' . $icon_class . '"></span> '; echo $cat->name . '</a>'; }
<div class="row kb-cat-parent-row"> <?php /* Start the subcategory loop */ ?> <?php $cat_iterator = 0; foreach ($sub_categories as $scat) { ?> <?php $sterm_meta = get_option('ipt_kb_category_meta_' . $scat->term_id, array()); ?> <?php $sterm_link = esc_url(get_category_link($scat)); ?> <?php $scat_totals = ipt_kb_total_cat_post_count($scat->term_id); ?> <?php $scat_posts = new WP_Query(array('cat' => $scat->term_id, 'posts_per_page' => get_option('posts_per_page', 5))); ?> <div class="col-md-6 kb-subcat"> <div class="col-md-3 col-sm-2 hidden-xs kb-subcat-icon"> <p class="text-center"> <a href="<?php echo $sterm_link; ?> " class="thumbnail"> <?php if (isset($sterm_meta['icon_class']) && '' != $sterm_meta['icon_class']) { ?> <i class="glyphicon <?php
<h3 class="panel-title"><?php _e('Knowledge Base', 'ipt_kb'); ?> </h3> </div> <div class="panel-body"> <div class="list-group"> <?php foreach ($main_categories as $cat) { ?> <a rel="bookmark" class="list-group-item kb-list-date kb-post-list" href="<?php echo esc_url(get_category_link($cat->term_id)); ?> "> <span class="badge"><?php echo ipt_kb_total_cat_post_count($cat->term_id); ?> </span> <?php echo $cat->name; ?> </a> <?php } ?> </div> </div> </div> </div> </div>
*/ global $term_meta, $cat, $cat_id, $wp_query; // Check if the current category is not a first level category // This will happen if the current category does not have any child // If this is the case, then we simply show all it's posts // Instead of the nice knowledgebase type things if ($cat->parent != '0') { $parent_cat = get_category($cat->parent); while ($parent_cat->parent != '0') { $parent_cat = get_category($parent_cat->parent); } $pterm_meta = get_option('ipt_kb_category_meta_' . $parent_cat->term_id, array()); } else { $pterm_meta = $term_meta; } $pcat_totals = ipt_kb_total_cat_post_count($cat_id); ?> <?php if (have_posts()) { ?> <header class="kb-parent-category-header"> <div class="col-sm-3 col-lg-2 kb-subcat-icon hidden-xs"> <p class="text-center"> <a href="<?php echo esc_url(get_category_link($cat)); ?> " class="thumbnail"> <?php if (isset($term_meta['icon_class']) && '' != $term_meta['icon_class']) { ?>