Advertisement
Guest User

Category get categories.

a guest
Aug 5th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.91 KB | None | 0 0
  1. <?php // Get variables
  2.  
  3. global $def_cat_style;
  4.  
  5. $get_id_parent_cat = get_term_by( 'slug', $company_category, 'company_category' );
  6.  
  7. $args = array(
  8.  
  9.     'child_of' => $get_id_parent_cat->term_id ,
  10.  
  11.     'parent' => get_query_var(''),
  12.  
  13.     'orderby' => 'name',
  14.  
  15.     'order' => 'ASC',
  16.  
  17.     'hide_empty' => 0,
  18.  
  19.     'hierarchical' => 0,
  20.  
  21.     'taxonomy' => 'company_category',
  22.  
  23.     'pad_counts' => true );
  24.  
  25. $categories = get_categories($args);
  26.  
  27. ?>
  28.  
  29.  
  30.  
  31. <?php if (count($categories) > 0): ?>
  32.  
  33.  
  34.  
  35.     <div class="subcategories-items-list">
  36.  
  37.  
  38.  
  39.         <?php foreach($categories as $category): ?>
  40.  
  41.  
  42.  
  43.         <?php
  44.  
  45.         $cat_id = $category->term_id;
  46.  
  47.         $color = get_option( 'metrodir_category_'.$cat_id.'_color', '' );
  48.  
  49.         $icon = get_option( 'metrodir_category_'.$cat_id.'_icon', '' );
  50.  
  51.         $custom_icon = get_option( 'metrodir_category_'.$cat_id.'_icon_image', '' );
  52.  
  53.         if ($opt_metrodir_home_category_image == "true") {
  54.  
  55.             $image = get_option( 'metrodir_category_'.$cat_id.'_image', '' );
  56.  
  57.         }
  58.  
  59.         ?>
  60.  
  61.  
  62.  
  63.         <div class="category-item-block<?php if ($opt_metrodir_category_version == "new-hidden") echo ' hidden'; ?>">
  64.  
  65.  
  66.  
  67.             <div class="category-item-header<?php if ($opt_metrodir_category_version == "new-hidden") echo ' hidden'; ?>">
  68.  
  69.  
  70.  
  71.                 <?php if (isset($image) AND $image): ?>
  72.  
  73.  
  74.  
  75.                     <div class="category-item-image">
  76.  
  77.                         <?php if ($opt_metrodir_category_version == "new-hidden"): ?>
  78.  
  79.                             <a class="opacity" style="background-image: url(<?php echo $image; ?>);"></a>
  80.  
  81.                         <?php else: ?>
  82.  
  83.                             <a class="opacity" href="<?php echo get_term_link(intval($category->term_id), 'company_category'); ?>" title="<?php echo $category->name; ?>" style="background-image: url(<?php echo $image; ?>);"></a>
  84.  
  85.                         <?php endif; ?>
  86.  
  87.                     </div>
  88.  
  89.  
  90.  
  91.                 <?php else: ?>
  92.  
  93.  
  94.  
  95.                     <div class="category-item-icon<?php if ($custom_icon) echo ' custom'; ?>">
  96.  
  97.  
  98.  
  99.                         <?php if ($opt_metrodir_category_version == "new-hidden"): ?>
  100.  
  101.                             <a title="<?php echo $category->name; ?>" style="background-color:<?php if ($color) echo $color; else if ($def_cat_style[$category->slug]["color"]) echo $def_cat_style[$category->slug]["color"]; else echo $def_cat_style["default"]["color"]; ?>;">
  102.  
  103.                                 <?php if ($custom_icon): ?>
  104.  
  105.                                     <i class="custom-icon" style="background-image: url(<?php echo $custom_icon ?>);"></i>
  106.  
  107.                                 <?php elseif ($icon): ?>
  108.  
  109.                                     <i class="fa <?php echo $icon; ?> fa-2x"></i>
  110.  
  111.                                 <?php elseif ($def_cat_style[$category->slug]["icon"]): ?>
  112.  
  113.                                     <i class="fa <?php echo $def_cat_style[$category->slug]["icon"]; ?> fa-2x"></i>
  114.  
  115.                                 <?php else: ?>
  116.  
  117.                                     <i class="fa <?php echo $def_cat_style["default"]["icon"]; ?> fa-2x"></i>
  118.  
  119.                                 <?php endif; ?>
  120.  
  121.                             </a>
  122.  
  123.                         <?php else: ?>
  124.  
  125.                             <a href="<?php echo get_term_link(intval($category->term_id), 'company_category'); ?>" title="<?php echo $category->name; ?>" style="background-color:<?php if ($color) echo $color; else if ($def_cat_style[$category->slug]["color"]) echo $def_cat_style[$category->slug]["color"]; else echo $def_cat_style["default"]["color"]; ?>;">
  126.  
  127.                                 <?php if ($custom_icon): ?>
  128.  
  129.                                     <i class="custom-icon" style="background-image: url(<?php echo $custom_icon ?>);"></i>
  130.  
  131.                                 <?php elseif ($icon): ?>
  132.  
  133.                                     <i class="fa <?php echo $icon; ?> fa-2x"></i>
  134.  
  135.                                 <?php elseif ($def_cat_style[$category->slug]["icon"]): ?>
  136.  
  137.                                     <i class="fa <?php echo $def_cat_style[$category->slug]["icon"]; ?> fa-2x"></i>
  138.  
  139.                                 <?php else: ?>
  140.  
  141.                                     <i class="fa <?php echo $def_cat_style["default"]["icon"]; ?> fa-2x"></i>
  142.  
  143.                                 <?php endif; ?>
  144.  
  145.                             </a>
  146.  
  147.                         <?php endif; ?>
  148.  
  149.                     </div>
  150.  
  151.  
  152.  
  153.                 <?php endif; ?>
  154.  
  155.  
  156.  
  157.                 <?php
  158.  
  159.                 $class_overflow = '';
  160.  
  161.                 $strlen_trnm = strlen ( $category->name );
  162.  
  163.                 if($strlen_trnm >= 14) {
  164.  
  165.                     $class_overflow = ' overflow';
  166.  
  167.                 }
  168.  
  169.                 ?>
  170.  
  171.  
  172.  
  173.                 <div class="category-item-title-container" style="background-color:<?php if ($color) echo $color; else if ($def_cat_style[$category->slug]["color"]) echo $def_cat_style[$category->slug]["color"]; else echo $def_cat_style["default"]["color"]; ?>;">
  174.  
  175.  
  176.  
  177.                     <?php if ($opt_metrodir_category_version == "new-hidden"): ?>
  178.  
  179.                     <a title="<?php echo $category->name; ?>">
  180.  
  181.                         <?php else: ?>
  182.  
  183.                         <a href="<?php echo get_term_link(intval($category->term_id), 'company_category'); ?>" title="<?php echo $category->name; ?>">
  184.  
  185.                             <?php endif; ?>
  186.  
  187.  
  188.  
  189.                             <div class="category-item-title<?php echo $class_overflow; ?>"><?php echo $category->name; ?></div>
  190.  
  191.  
  192.  
  193.                             <div class="category-item-count">(<?php echo $category->count; ?>)</div>
  194.  
  195.  
  196.  
  197.                         </a>
  198.  
  199.  
  200.  
  201.                 </div>
  202.  
  203.  
  204.  
  205.             </div>
  206.  
  207.  
  208.  
  209.         </div>
  210.  
  211.  
  212.  
  213.         <?php endforeach; ?>
  214.  
  215.  
  216.  
  217.     <div class="clear"></div>
  218.  
  219.  
  220.  
  221.     </div>
  222.  
  223.  
  224.  
  225. <?php endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement