Guest User

Untitled

a guest
Dec 22nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. function get_custom_category() {
  2.  
  3. $buffy = '';
  4.  
  5. $buffy .= '<ul class="td-category">';
  6. $categories = get_the_category($this->post->ID);
  7. $cat_array = array();
  8.  
  9. if($categories){
  10. foreach($categories as $category) {
  11. if ($category->name != TD_FEATURED_CAT) { //ignore the featured category name
  12. //get the parent of this cat
  13. $td_parent_cat_obj = get_category($category->category_parent);
  14.  
  15. //if we have a parent, shot it first
  16. if (!empty($td_parent_cat_obj->name)) {
  17. $tax_meta__color_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID,'tdc_color');//swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_color');
  18. $tax_meta__hide_on_post_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID,'tdc_hide_on_post');//swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_hide_on_post');
  19. $cat_array[$td_parent_cat_obj->name] = array(
  20. 'color' => $tax_meta__color_parent,
  21. 'link' => get_category_link($td_parent_cat_obj->cat_ID),
  22. 'hide_on_post' => $tax_meta__hide_on_post_parent
  23. );
  24. }
  25.  
  26. //show the category, only if we didn't already showed the parent
  27. $tax_meta_color = td_util::get_category_option($category->cat_ID,'tdc_color');//swich by RADU A, get_tax_meta($category->cat_ID,'tdc_color');
  28. $tax_meta__hide_on_post_parent = td_util::get_category_option($category->cat_ID,'tdc_hide_on_post');//swich by RADU A, get_tax_meta($category->cat_ID,'tdc_hide_on_post');
  29. $cat_array[$category->name] = array(
  30. 'color' => $tax_meta_color,
  31. 'link' => get_category_link($category->cat_ID),
  32. 'hide_on_post' => $tax_meta__hide_on_post_parent
  33. );
  34. }
  35. }
  36. }
  37.  
  38. foreach ($cat_array as $td_cat_name => $td_cat_parms) {
  39. if ($td_cat_parms['hide_on_post'] == 'hide') {
  40. continue;
  41. }
  42.  
  43. if (!empty($td_cat_parms['color'])) {
  44. $td_cat_color = ' style="background-color:' . $td_cat_parms['color'] . ';"';
  45. } else {
  46. $td_cat_color = '';
  47. }
  48.  
  49.  
  50. $buffy .= '<li class="entry-category"><span>' . $td_cat_name . '</span></li>';
  51. }
  52. $buffy .= '</ul>';
  53.  
  54. return $buffy;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment