Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function exclude_post_categories($excl='', $spacer=''){
- $categories = get_the_category($post->ID);
- if(!empty($categories)){
- $exclude=$excl;
- $exclude = explode(",", $exclude);
- foreach ($categories as $child){
- $parents = get_category_parents($child->cat_ID, FALSE, ',');
- $parents = explode(',', $parents);
- foreach($exclude as $excluded){
- if (in_array($excluded, $parents)){
- $excluded_children[] = $child->cat_ID;
- }
- }
- }
- $thecount = count(get_the_category()) - count($excluded_children);
- foreach ($categories as $cat) {
- $html = '';
- if(!in_array($cat->cat_ID, $excluded_children)) {
- $html .= '<a href="' . get_category_link($cat->cat_ID) . '" ';
- $html .= 'title="' . $cat->cat_name . '">' . $cat->cat_name . '</a>';
- if($thecount>1){
- $html .= $spacer;
- }
- $thecount--;
- echo $html;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement