Advertisement
Guest User

Untitled

a guest
Mar 9th, 2011
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. function exclude_post_categories($excl='', $spacer=''){
  2.    $categories = get_the_category($post->ID);
  3.       if(!empty($categories)){
  4.         $exclude=$excl;
  5.         $exclude = explode(",", $exclude);
  6.         foreach ($categories as $child){
  7.           $parents = get_category_parents($child->cat_ID, FALSE, ',');
  8.           $parents = explode(',', $parents);
  9.           foreach($exclude as $excluded){
  10.            if (in_array($excluded, $parents)){
  11.                $excluded_children[] = $child->cat_ID;
  12.            }
  13.           }
  14.         }
  15.         $thecount = count(get_the_category()) - count($excluded_children);
  16.         foreach ($categories as $cat) {
  17.             $html = '';
  18.             if(!in_array($cat->cat_ID, $excluded_children)) {
  19.                 $html .= '<a href="' . get_category_link($cat->cat_ID) . '" ';
  20.                 $html .= 'title="' . $cat->cat_name . '">' . $cat->cat_name . '</a>';
  21.                 if($thecount>1){
  22.                     $html .= $spacer;
  23.                 }
  24.             $thecount--;
  25.             echo $html;
  26.             }
  27.           }
  28.       }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement