Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //a filter function to exclude all child categories of cat 36 from the_category()
- //
- add_filter('the_category', 'the_category_exclude_parent_36');
- function the_category_exclude_parent_36($list) {
- global $post;
- $categories = get_the_category( $post->ID );
- $thelist = ''; $separator = ', ';
- $i = 0;
- foreach ( $categories as $category ) {
- if( $category->category_parent != 36 ) :
- if ( 0 < $i )
- $thelist .= $separator;
- $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
- ++$i;
- endif;
- }
- return $thelist;
- }
- //
- //end of the filter function to exclude all child categories of cat 36
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement